日期:2014-05-18 浏览次数:20847 次
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <NewCont> <BaseInfo> <Missionid>00000000000058824904</Missionid> <SubMissionid>1</SubMissionid> <ActivityId>0000001002</ActivityId> <Managecom>86440601</Managecom> <PrtSeq>8104401614213</PrtSeq> <ContNo>00000035725392</ContNo> </BaseInfo> <ContInfo> <LCCont> <ContNo>00000035725392</ContNo> <PolApplyDate>2012-06-22</PolApplyDate> <CvaliDate>2012-06-22</CvaliDate> <AgentCode>37054128</AgentCode> <AgentName>黄东生</AgentName> </LCCont> </ContInfo> </NewCont>
protected void Page_Load(object sender, EventArgs e) { var str = "Missionid=00000000000058824904;SubMissionid=1;ActivityId=0000001002;AgentCode=37054128;CvaliDate=2012-06-22;ContNo=00000035725392"; var xml0 = @"<BaseInfo> <Missionid>{0}</Missionid> <SubMissionid>{1}</SubMissionid> <ActivityId>{2}</ActivityId> <Managecom>{3}</Managecom> <PrtSeq>{4}</PrtSeq> <ContNo>{5}</ContNo> </BaseInfo>"; var xml = string.Format(xml0, GetValue(str,"Missionid"), GetValue(str,"SubMissionid"), GetValue(str,"ActivityId"), GetValue(str,"Managecom"), GetValue(str,"PrtSeq"), GetValue(str,"ContNo")); TextBox1.Text = xml; } string GetValue(string inStr,string filedName) { var reg = filedName + "=([^;]+)"; var m = Regex.Match(inStr, reg); return m.Success ? m.Groups[1].Value : ""; }