<?xml version='1.0' encoding='GBK'?>
<FP>
<FPXX>
<FPXXMX>
<fpdm>115061426954</fpdm>
<fphm>00002757</fphm>
<saveCode>01</saveCode>
<saveMessage>节点【HYFL】的值填写不对,请参照福建自营业系统文档说明</saveMessage>
</FPXXMX>
<returnCode>00</returnCode>
<returnMessage>
<cgfs>0</cgfs>
<sbfs>1</sbfs>
<yczfs>0</yczfs>
</returnMessage>
</FPXX>
</FP>
<?xml version='1.0' encoding='GBK'?>
<FP>
<FPXX>
<fpdm>133010810135</fpdm>
<fphm>90067001</fphm>
<saveCode>00</saveCode>
<saveMessage>保存成功</saveMessage>
</FPXX>
</FP>
<?xml version="1.0" encoding="GBK"?>
<FP>
<FPXX>
<returnCode>01</returnCode>
<returnMessage>Error on line 2 of document : The XML declaration may only appear at the very beginning of the document. Nested exception: The XML declaration may only appear at the very beginning of the document.</returnMessage>
</FPXX>
</FP>
先来个原理简示,有空再补个分解式的类
foreach (XmlElement birthday in dom.DocumentElement.ChildNodes)
{
//读取数据
if (birthday.SelectSingleNode("fpdm") != null)
fpdm = birthday.SelectSingleNode("fpdm").InnerText;
else if (birthday.SelectSingleNode("FPXXMX/fpdm") != null)
fpdm = birthday.SelectSingleNode("FPXXMX/fpdm").InnerText;
//读取数据
if (birthday.SelectSingleNode("fphm") != null)
fphm = birthday.SelectSingleNode("fphm").InnerText;
else if (birthday.SelectSingleNode("FPXXMX/fphm") != null)
fphm = birthday.SelectSingleNode("FPXXMX/fphm").InnerText;
//读取数据
if (birthday.SelectSingleNode("saveCode") != null)
saveCode = birthday.SelectSingleNode("saveCode").InnerText;
else if (birthday.SelectSingleNode("FPXXMX/saveCode") != null)
saveCode = birthday.SelectSingleNode("FPXXMX/saveCode").InnerText;
//读取数据
if (birthday.SelectSingleNode("saveMessage") != null)
saveMessage = birthday.SelectSingleNode("saveMessage").InnerText;
else if (birthday.SelectSingleNode("FPXXMX/saveMessage") != null)
saveMessage = birthday.SelectSingleNode("FPXXMX/saveMessage").InnerText;
if (birthday.SelectSingleNode("returnCode") != null)
returnCode = birthday.SelectSingleNode("returnCode").InnerText;
if (birthday.SelectSingleNode("returnMessage") != null)
returnMessage = birthday.SelectSingleNode("returnMessage").InnerText;
}