110,530
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<!-- XmlComment -->
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="TEST">
<title lang="en">H P</title>
<author>J K. R</author>
<year>2012</year>
<price>00.00</price>
</book>
</bookstore>
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"D:\test.xml");
XmlNode xNode = xmlDoc.SelectSingleNode("//*[starts-with(name(),'p')][last()]");
if (xNode == null)
{
MessageBox.Show("null");
}
else
{
MessageBox.Show(xNode.InnerXml);
}