【发布时间】:2016-01-24 16:09:11
【问题描述】:
在过去的 2 个小时里,我尝试将 xml 解析为 json。 在我做的一个示例项目中,我是这样做的:
string xmlString = XDocument.Load("G00011071.xml").ToString();
XmlDocument xml = new XmlDocument();
xml.LoadXml(xmlString);
var json = Newtonsoft.Json.JsonConvert.SerializeObject(xml);
它工作得很好..
当我尝试将它集成到我需要在那里使用它的项目中时 我有一个错误:
An exception of type 'System.IO.FileLoadException' occurred in xmloutput.dll but was not handled in user code.
Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我试图解决它,但没有任何帮助 - 所以我决定不使用 Json.net 并寻找替代方案,我发现post:
但我的 XML 结构比那里使用的要复杂得多..
我怎样才能达到与 Json.net 产生的结果相同的结果?
【问题讨论】:
-
你能上传你的xml文件吗?
-
怎么发啊,这里太长了..?
-
pastebin.com 例如
-
@Micky 建议的解决方案不符合我的需求.. 那为什么要重复?
标签: c# json xml xml-parsing