下面的這一行拋出一個NullReferenceException。GetNodeByXpath拋出NullReferenceException
Node nodeEmail = Node.GetNodeByXpath("//Member/email[text()='xxx']");
和我有
<root id="-1">
<Members>
<Member id="15853" ...>
<email>xxx</email>
</Member>
...
例外:
[NullReferenceException: Object reference not set to an instance of an object.]
umbraco.NodeFactory.Node.initialize() +172
umbraco.NodeFactory.Node..ctor(XmlNode NodeXmlNode) +179
umbraco.NodeFactory.Node.GetNodeByXpath(String xpath) +168
這是我第一次嘗試的XPath。它在Umbraco 6.
我做錯了什麼?
更多信息
以下的罰款:
Node nodeEmail = Node.GetNodeByXpath("//Members");
Node nodeEmail = Node.GetNodeByXpath("//Members/Member");
Node nodeEmail = Node.GetNodeByXpath("//Member");
但是,這將引發同樣的異常
Node nodeEmail = Node.GetNodeByXpath("//Members/Member/email");
從你發佈的xpath和XML到目前爲止,沒有錯。這應該工作,你可以測試xpath [這裏](http://www.freeformatter.com/xpath-tester.html)(或任何其他xpath測試器)。 – har07