C# xml2json
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# xml2json相关的知识,希望对你有一定的参考价值。
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 using System.Xml; 8 9 namespace xml2json 10 { 11 public partial class WebForm1 : System.Web.UI.Page 12 { 13 protected void Page_Load(object sender, EventArgs e) 14 { 15 string xml = @"<dataestimate> 16 <OwnerName>CRM06手机端赵雅琪</OwnerName> 17 <StepName>赵雅琪</StepName> 18 <DEName>测试环境跑流程---1</DEName> 19 <ID>150F2263-C56A-E611-80C0-00155DB6760B</ID> 20 <CPName>测试环境跑流程</CPName> 21 <AccountInfoName>crm06专属客户</AccountInfoName> 22 <AccountName>艾迪美通</AccountName> 23 <Saler>CRM06手机端赵雅琪</Saler> 24 <SalerList>CRM01杨静</SalerList> 25 <EFTypeValues>1197CF3B-C56A-E611-80C0-00155DB6760B;1297CF3B-C56A-E611-80C0-00155DB6760B</EFTypeValues> 26 <Monitor>是</Monitor> 27 <Budget>234.00</Budget> 28 <Reason>2344</Reason> 29 <OwnerSType>100000000</OwnerSType> 30 <OPOwnerSType>100000000</OPOwnerSType> 31 <effecttype> 32 <effecttype> 33 <EFID>662AC533-C56A-E611-80C0-00155DB6760B</EFID> 34 <EFName>CPC</EFName> 35 </effecttype> 36 <effecttype> 37 <EFID>1197CF3B-C56A-E611-80C0-00155DB6760B</EFID> 38 <EFName>CPM</EFName> 39 </effecttype> 40 <effecttype> 41 <EFID>1297CF3B-C56A-E611-80C0-00155DB6760B</EFID> 42 <EFName>PV</EFName> 43 </effecttype> 44 <effecttype> 45 <EFID>D7849F46-C56A-E611-80C0-00155DB6760B</EFID> 46 <EFName>点击</EFName> 47 </effecttype> 48 </effecttype> 49 </dataestimate>"; 50 51 XmlDocument doc = new XmlDocument(); 52 doc.LoadXml(xml); 53 string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc); 54 55 56 57 Response.Write(json); 58 59 } 60 } 61 }
以上是关于C# xml2json的主要内容,如果未能解决你的问题,请参考以下文章