C# xml2json

时间:2021-05-14 16:24:50
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml; namespace xml2json
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string xml = @"<dataestimate>
<OwnerName>CRM06手机端赵雅琪</OwnerName>
<StepName>赵雅琪</StepName>
<DEName>测试环境跑流程---1</DEName>
<ID>150F2263-C56A-E611-80C0-00155DB6760B</ID>
<CPName>测试环境跑流程</CPName>
<AccountInfoName>crm06专属客户</AccountInfoName>
<AccountName>艾迪美通</AccountName>
<Saler>CRM06手机端赵雅琪</Saler>
<SalerList>CRM01杨静</SalerList>
<EFTypeValues>1197CF3B-C56A-E611-80C0-00155DB6760B;1297CF3B-C56A-E611-80C0-00155DB6760B</EFTypeValues>
<Monitor>是</Monitor>
<Budget>234.00</Budget>
<Reason>2344</Reason>
<OwnerSType>100000000</OwnerSType>
<OPOwnerSType>100000000</OPOwnerSType>
<effecttype>
<effecttype>
<EFID>662AC533-C56A-E611-80C0-00155DB6760B</EFID>
<EFName>CPC</EFName>
</effecttype>
<effecttype>
<EFID>1197CF3B-C56A-E611-80C0-00155DB6760B</EFID>
<EFName>CPM</EFName>
</effecttype>
<effecttype>
<EFID>1297CF3B-C56A-E611-80C0-00155DB6760B</EFID>
<EFName>PV</EFName>
</effecttype>
<effecttype>
<EFID>D7849F46-C56A-E611-80C0-00155DB6760B</EFID>
<EFName>点击</EFName>
</effecttype>
</effecttype>
</dataestimate>"; XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc); Response.Write(json); }
}
}