How to unmarshal XML attributes with colons?

前端 未结 1 395
半阙折子戏
半阙折子戏 2021-02-04 11:36

Some SVG/XML files I\'m working with have dashes and colons in attribute names - for example:


  

        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 11:47

    Your example fragment is not quite correct, since it does not include an XML namespace binding for the xlink: prefix. What you probably want is:

    
      lala
    
    

    You can unmarshal this attribute using the namespace URL:

    XlinkHref string `xml:"http://www.w3.org/1999/xlink href,attr"`
    

    Here is an updated copy of your example program with the namespace fix.

    0 讨论(0)
提交回复
热议问题