[Question] XML to JSON and parsing

polaris · · 28 次点击    
<p>I need to parse variety of XMLs that can look like this (simplified):</p> <p>&lt;configuration&gt; &lt;connections&gt; &lt;add key=&#34;foo&#34; connection=&#34;bar&#34; /&gt; &lt;/connections&gt; &lt;appSetting&gt; &lt;add name=&#34;foo&#34; value=&#34;bar&#34; /&gt; ... &lt;/appSetting&gt;</p> <pre><code>others that are specific to some other XMLs </code></pre> <p>I am interested in collecting the file path+filename,xml attributes and values and transforming it all to simple json { &#34;k&#34;:&#34;v&#34;}.</p> <p>To me the easiest way would be to use something like this <a href="https://github.com/clbanning/mxj" rel="nofollow">https://github.com/clbanning/mxj</a></p> <hr/>**评论:**<br/><br/>Savedya: <pre><p>Feel free to use whatever libraries you want, but you can do this with the standard library pretty easily.</p> <p><a href="https://play.golang.org/p/BPLxVI8E1H" rel="nofollow">https://play.golang.org/p/BPLxVI8E1H</a></p></pre>
28 次点击  
加入收藏 微博
0 回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传