2
我有下面的XML:XPath查詢選擇節點
<?xml version="1.0" encoding="utf-8"?>
<Persons>
<Person>
<PersonID>6352</PersonID>
<Forename>Tristan</Forename>
</Person>
<Person>
<PersonID>6353</PersonID>
<Forename>Ruth</Forename>
</Person>
<Person>
<PersonID>6913</PersonID>
<Forename>Mina</Forename>
<Surname>Asif</Surname>
</Person>
<Person>
<PersonID>6914</PersonID>
<Forename>Clark</Forename>
<Surname>Williams</Surname>
</Person>
</Persons>
我用下面的代碼加載XML:
XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"example.xml");
我要問,對於不具有的所有節點使用XPath查詢和選擇節點調用(類似於下面的僞東西)姓:
XmlNodeList nodes1 = xDoc.SelectNodes("//Person[Surname=null]");
我是很新,XPath的,任何p非常感謝!
看一看http://stackoverflow.com/questions/15620469/xslt-xpath-test-for-null – lloyd