我负责翻录和剥离XFDL文件中的相关数据。我试图使用XmlDocument的SelectSignleNode方法来做到这一点。但是,它被证明是不成功的。解析XFDL内容 - C#
Represntative XML:
<XFDL>
...
<page1>
<check3>true</check3>
</page1>
...
<page sid="PAGE1">
<check sid="CHECK9">
<value>true</value>
</check>
</page>
...
代码:
XmlDocument document = new XmlDocument();
document.Load(memoryStream);//decoded and unzipped xfdl file
//Doesn't work
XmlNode checkBox = document.SelectSingleNode("//check[@sid='CHECK9']/value");
//Doesn't work
XmlNode checkBox = document.SelectSingleNode("//page[@sid='PAGE1']/check[@sid='CHECK9']");
MsgBox(checkBox.InnerXml);
息率我System.NullReferenceException没有被选中的XMLNode。
我想我有一个xpath的问题,但我似乎无法理解在哪里。较早的xml节点很容易使用:
XmlNode checkBox = document.SelectSingleNode("//page1/check3");
MsgBox(checkBox.InnerText);
显示正常。并且只是在通行证中出现问题,<page1>
标记中没有<check9></check9>
的定义。
任何人都有一些见解?
在此先感谢。
是否有可能导致从XPath的多个节点? –
第一个:是的。第二个:号码 我不瘦我缺少一个嵌套的路径,要么。 – mcwagner
通过在IE中打开XML来验证完全枚举的xpath如下:xfdl> page> check> value。我错过了什么? – mcwagner