评论会员:SAKryukov 时间:2012/02/07
我支持的方法解释由lukeer,但我没有提到的序列化方法。你可以做的更好,更容易使用资料合约。
看到{A1}]
我解释为什么它这么好,在我过去的解决方案:
{A2}
{A3}]
mdash; SA:gmhussain007 | |的DataSet DS =新的DataSet();
DS = Obj_Common.FillDataset("4 proc_hospitalizationdetails_FORXML,"strRegNo"','',''","的TableName");
如果(ds.Tables ["的TableName"] Rows.Count GT; 0)
{
; XmlDocument的XD_PDemographics新的XmlDocument();
/ /写XML声明
的XmlDeclaration的XmlDeclaration = XD_PDemographics.CreateXmlDeclaration("1.0","UTF-8",NULL)
60; / /创建根元素
&
#160; XmlElement的MainNode = XD_PDemographics.CreateElement("PDData");
XD_PDemographics.InsertBefore(的XmlDeclaration,XD_PDemographics.DocumentElement)
MainNode.SetAttribute("XMLNS:XSD","http://www.w3.org/2001/XMLSchema");
MainNode.SetAttribute("XMLNS:XSI","http://www.w3.org/2001/XMLSchema-instance");
XD_PDemographics.AppendChild(MainNode)
&
#160; / ****************************************节点2 ******* ***************************************** /
/ /为节点的父节点
1
60; XmlElement的则idNode = XD_PDemographics.CreateElement("ID");/ /父节点
&
#160; XD_PDemographics.DocumentElement.PrependChild(则idNode)的;
XD_PDemographics.CreateElement的XmlElement的CID =("来电显示");对于病房父节点
/ /节点 的XmlElement的PID = XD_PDemographics.CreateElement("PID控制");
0; XmlElement的YID = XD_PDemographics.CreateElement("YID");
XmlElement的密码= XD_PDemographics.CreateElement("密码");
XMLTEXT PIDValue XD_PDemographics.CreateTextNode(ds.Tables ["TableName的"行[0] ["PID控制"]的ToString(),TRIM()。)
; PID.AppendChild(PIDValue)
&
#160;
160; IdNode.AppendChild(CID);
IdNode.AppendChild(PID)
IdNode.AppendChild(YID)
IdNode.AppendChild(PWD);
; / ****************************************节点2 ******* ***************************************** /
0;
/ /为节点的父节点
160; 的XmlElement的PD = XD_PDemographics.CreateElement("帕金森病");
0; XD_PDemographics.DocumentElement.PrependChild(PD);
PID.AppendChild(PIDValue)
XmlElement的FN = XD_PDemographics.CreateElement]("新生力量");/ /第一名称
XMLTEXT FNValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["FName参数的ToString()TRIM())
; FN.AppendChild(FNValue)
XmlElement的LN = XD_PDemographics.CreateElement("法律公告");/ /最后的名字
&
#160; XMLTEXT LNValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["LNAME"]的ToString()TRIM())
;LN.AppendChild(LNValue)
XmlElement的二氧化碳= XD_PDemographics.CreateElement("公司");/ /
护理 XMLTEXT COValue的= XD_PDemographics.CreateTextNode(ds.Tables ["TableName的"行[0] ["公司"]。的ToString()TRIM())
60; CO.AppendChild(COValue)
("G")进行的XmlElementĞ= XD_PDemographics.CreateElement ;/ /性别
60; XMLTEXT的GValue = XD_PDemographics.CreateTextNode(。ds.Tables ["TableName的"行[0] ["性别"的ToString()TRIM())
; G.AppendChild(的GValue)
160; XmlElement的BG = XD_PDemographics.CreateElement("保函");/ / BloodGroup
160; XMLTEXT BGValue = &
#160; BG.AppendChild(BGValue)
160; XmlElement的出生日期= XD_PDemographics.CreateElement("出生日期");/ /出生日期
0; XMLTEXT DOBValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["出生"的ToString()TRIM())
DOB.AppendChild(DOBValue)
的XmlElement的CP = XD_PDemographics.CreateElement("CP");/ /
护理 字符串strCo = ds.Tables ["TableName的"行[0] ["STDCode"]的ToString(),TRIM()。" - "。ds.Tables ["TableName的"行[0] ["ContactNO"] 。的ToString()TRIM();
XMLTEXT CPValue,= XD_PDemographics.CreateTextNode(strCo)
CP.AppendChild(CPValue)
XmlElement的地址= XD_PDemographics.CreateElement("地址");/ /地址
XMLTEXT创值= &
#160; ADD.AppendChild(创值);
XmlElement的石油公司DNO = XD_PDemographics.CreateElement(DNO");/ /石油公司DNO
&
#160; XMLTEXT DNOValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["配网运营商"的ToString()TRIM())
&
#160; DNO.AppendChild(DNOValue)
0; 的XmlElement = XD_PDemographics.CreateElement("甲");/ /地区
160; 安勤的XmlText = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["AreaName"]的ToString()TRIM())
A.AppendChild(安勤)
的XmlElement的STR = XD_PDemographics.CreateElement("乙方");/ /街道名称
XMLTEXT将strValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["StreetName"]的ToString()TRIM())
STR.AppendChild(strValue的);
XmlElement的CTY = XD_PDemographics.CreateElement(CTY");/ /城市名称
XMLTEXT CTYValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["CityName"]的ToString()TRIM())
160; CTY.AppendChild(CTYValue)
; XmlElement的:D = XD_PDemographics.CreateElement(的"D");/ / Distric名称
&
#160; XMLTEXT DValue =
160; D.AppendChild(DValue)
&
#160; XmlElement的科技教育= XD_PDemographics.CreateElement("科技教育");/ /国家名称
160; XMLTEXT STEValue = XD_PDemographics.CreateTextNode(。。ds.Tables ["TableName的"行[0] ["StateName"]的ToString()TRIM())
160;STE.AppendChild(STEValue)
; XmlElement的点击率= XD_PDemographics.CreateElement("点击率");/ /国家名称
160; XMLTEXT CTRValue =
;CTR.AppendChild(CTRValue)
160; PD.AppendChild(FN);
0; PD.AppendChild(LN);
PD.AppendChild(CO);
160; PD.AppendChild(G)
60; PD.AppendChild(BG)
&
#160; PD.AppendChild(出生);
PD.AppendChild(CP);
160; PD.AppendChild(地址);
160; PD.AppendChild(石油公司DNO)
160; PD.AppendChild(A)
160; PD.AppendChild(STR)
0; PD.AppendChild(CTY)
PD.AppendChild(STE)
160; PD.AppendChild(CTR);
160;
/ *******************************************节点3 **** ***************************************** /
60; XmlElement的船务= XD_PDemographics.CreateElement("船务");/ /父节点
0; XD_PDemographics.DocumentElement.PrependChild(船务);
XmlElement的PSTT = XD_PDemographics.CreateElement(PSTT")的;对于病房的父节点
/ /节点 XmlElement的HOSP的= XD_PDemographics.CreateElement(HOSP");
MISC.AppendChild(PSTT)
MISC.AppendChild(HOSP的);
160; / ************************************************* *************************************** /
&
#160; / /添加到主节点
MainNode.AppendChild(则idNode)的;
160; MainNode.AppendChild(PD);
0; MainNode.AppendChild(船务);
/ / FRO Crerate放大器;值保存到XML文件
/ / XD_PDemographics.Save(Server.MapPath()"/ CommonFolder / PatientDemographics.xml。");
XD_PDemographics.Save(System.Web.HttpContext.Current.Server.MapPath("〜")"/ CommonFolder /"strRegNo"的XML。");
回复于("XML文件创建");
Msgbox.Show("XML文件创建"); |