你可以使用带名称空间的形式来访问这个XML,而不是设法去掉。例如下的XML(XMLFile1.xml):<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="http://tempuri.org/XMLFile1.xsd">
<book>
<title> VB.NET</title>
<author>
<first_name>xu lei</first_name>
<last_name>chen bin</last_name>
</author>
<price>9.99</price>
</book>
<book>
<title>C#</title>
<author>
<first_name>yu zai yang </first_name>
<last_name>sun lei</last_name>
</author>
<price>8.88</price>
</book>
<book>
<title>ASP.NET</title>
<author>
<first_name>fan xin </first_name>
<last_name>zhang lei</last_name>
</author>
<price>7.77</price>
</book>
<book>
<title>VB</title>
<author>
<first_name>chen lei </first_name>
<last_name>liu jian</last_name>
</author>
<price>7.77</price>
</book>
</bookstore> XmlDocument doc = new XmlDocument();
doc.Load("XMLFile1.xml");
XmlNamespaceManager xmlns = new XmlNamespaceManager(doc.NameTable);
xmlns.AddNamespace("ns", "http://tempuri.org/XMLFile1.xsd");
int i = doc.DocumentElement.SelectNodes("/ns:bookstore/ns:book/ns:author", xmlns).Count;