<p>Okay guys, </p>
<p>Maybe somebody could give some insight here... I seem to be hitting a brick wall with the encoding/XML library.</p>
<p>For the life of me, I can't replicate the valid XML attributes from <gpx></p>
<p>Basically i'm unmarshalling the XML data from a GPS file, then marshalling it back into another file. Everything is working correctly, except the attribute tags for the root XML <gpx>.</p>
<p>I've tried various func (c *gpx) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {} type approaches to no avail. Basically I just want the root tag <GPX> to have all the attributes assigned correctly. Why you can't do </p>
<p>Attributes []xml.Attr <code>xml:",attr"</code>or something similar is beyond me. </p>
<p>Current issue tracker: <a href="https://github.com/golang/go/issues/3633" rel="nofollow">https://github.com/golang/go/issues/3633</a></p>
<p>Sample struct with code -> <a href="http://pastebin.com/gK0feeWH" rel="nofollow">http://pastebin.com/gK0feeWH</a>
Good XML header -> <a href="http://pastebin.com/XjEZuBa1" rel="nofollow">http://pastebin.com/XjEZuBa1</a>
Bad XML header -> <a href="http://pastebin.com/LnTckfAW" rel="nofollow">http://pastebin.com/LnTckfAW</a></p>
<p>Any help would be greatly appreciated, </p>
<p>Thank you.</p>
<hr/>**评论:**<br/><br/>Xonzo: <pre><p>I have an example in the Go playground if it helps...</p>
<p><a href="http://play.golang.org/p/J7wy6306Cj" rel="nofollow">http://play.golang.org/p/J7wy6306Cj</a></p>
<p>My program will replicate the GPS file exactly <strong>EXCEPT</strong> for the <gpx attribute> portion. If I replace the <GPX> tag at the top I can import my file into Garmin Basecamp with no issues. </p>
<p>Sadly other encoding libraries from other languages work correctly, but I would prefer to use Go.... <em>sigh</em></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传