【发布时间】:2015-04-17 19:09:54
【问题描述】:
我正在尝试如下加载 xml 文件并读取每个元素的值,但结果计数始终 = 零,在我的带有代码的 xml 示例下方
1) 我的 xml 是:
<ROOT xmlns="authenticateUser">
<PARTYCODE></PARTYCODE>
<VRETCODE>10</VRETCODE>
<PRETCODE>10</PRETCODE>
<VRETERR>Incorrect user name or password entered.</VRETERR>
</ROOT>
2) 我的代码是:
XDocument Doc = XDocument.Parse(strFileData);
var Result = (from Root in Doc.Descendants("ROOT")
select new
{
PARTYCODE = Root.Element("PARTYCODE").Value ?? string.Empty,
VRETCODE = Root.Element("VRETCODE").Value ?? string.Empty,
PRETCODE = Root.Element("PRETCODE").Value ?? string.Empty,
VRETERR = Root.Element("VRETERR").Value ?? string.Empty,
}).ToList();
【问题讨论】:
-
与经典 ASP 无关。