xml文件
net处理有命名空间的xml文件的方法_c#<?xml version="1.0" encoding="utf-8" ?>
net处理有命名空间的xml文件的方法_c#
<bk:bookstore xmlns:bk="http://www.contoso.com/books">
net处理有命名空间的xml文件的方法_c#  
<bk:book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
net处理有命名空间的xml文件的方法_c#    
<bk:title>The Autobiography of Benjamin Franklin</bk:title>
net处理有命名空间的xml文件的方法_c#    
<author>
net处理有命名空间的xml文件的方法_c#      
<first-name>Benjamin</first-name>
net处理有命名空间的xml文件的方法_c#      
<last-name>Franklin</last-name>
net处理有命名空间的xml文件的方法_c#    
</author>
net处理有命名空间的xml文件的方法_c#    
<price>8.99</price>
net处理有命名空间的xml文件的方法_c#  
</bk:book>
net处理有命名空间的xml文件的方法_c#  
<bk:book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
net处理有命名空间的xml文件的方法_c#    
<bk:title>2222</bk:title>
net处理有命名空间的xml文件的方法_c#    
<author>
net处理有命名空间的xml文件的方法_c#      
<first-name>Benjamin</first-name>
net处理有命名空间的xml文件的方法_c#      
<last-name>Franklin</last-name>
net处理有命名空间的xml文件的方法_c#    
</author>
net处理有命名空间的xml文件的方法_c#    
<price>8.99</price>
net处理有命名空间的xml文件的方法_c#  
</bk:book>
net处理有命名空间的xml文件的方法_c#  
<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
net处理有命名空间的xml文件的方法_c#    
<title>The Confidence Man</title>
net处理有命名空间的xml文件的方法_c#    
<author>
net处理有命名空间的xml文件的方法_c#      
<first-name>Herman</first-name>
net处理有命名空间的xml文件的方法_c#      
<last-name>Melville</last-name>
net处理有命名空间的xml文件的方法_c#    
</author>
net处理有命名空间的xml文件的方法_c#    
<price>11.99</price>
net处理有命名空间的xml文件的方法_c#  
</book>
net处理有命名空间的xml文件的方法_c#  
<book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
net处理有命名空间的xml文件的方法_c#    
<title>The Gorgias</title>
net处理有命名空间的xml文件的方法_c#    
<author>
net处理有命名空间的xml文件的方法_c#      
<name>Plato</name>
net处理有命名空间的xml文件的方法_c#    
</author>
net处理有命名空间的xml文件的方法_c#    
<price>9.99</price>
net处理有命名空间的xml文件的方法_c#  
</book>
net处理有命名空间的xml文件的方法_c#
</bk:bookstore>

C#代码
net处理有命名空间的xml文件的方法_c#
net处理有命名空间的xml文件的方法_c#        
string path = MapPath("~/app_data/XMLFile.xml");
net处理有命名空间的xml文件的方法_c#        XPathDocument document 
= new XPathDocument(path);
net处理有命名空间的xml文件的方法_c#        XPathNavigator navigator 
= document.CreateNavigator();
net处理有命名空间的xml文件的方法_c#
net处理有命名空间的xml文件的方法_c#
net处理有命名空间的xml文件的方法_c#        XmlNamespaceManager man 
= new XmlNamespaceManager(navigator.NameTable);
net处理有命名空间的xml文件的方法_c#        man.AddNamespace(
"bk1""http://www.contoso.com/books");
net处理有命名空间的xml文件的方法_c#        XPathExpression query 
= navigator.Compile("/bk1:bookstore/bk1:book/bk1:title");
net处理有命名空间的xml文件的方法_c#
net处理有命名空间的xml文件的方法_c#       query.SetContext(man);
net处理有命名空间的xml文件的方法_c#        
// Select all books authored by Melville.
net处理有命名空间的xml文件的方法_c#        
//XPathNodeIterator nodes = navigator.Select("descendant::book:book[book:author/last-name='Melville']",man);
net处理有命名空间的xml文件的方法_c#      
//  string query="/bk:bookstore/bk:book/bk:title";
net处理有命名空间的xml文件的方法_c#
        XPathNodeIterator nodes = navigator.Select(query);
net处理有命名空间的xml文件的方法_c#       
net处理有命名空间的xml文件的方法_c#        
while (nodes.MoveNext())
net处理有命名空间的xml文件的方法_c#_52net处理有命名空间的xml文件的方法_ide_53        
net处理有命名空间的xml文件的方法_ide_54{
net处理有命名空间的xml文件的方法_xml_55            
// Clone the navigator returned by the Current property. 
net处理有命名空间的xml文件的方法_xml_55            
// Use the cloned navigator to get the title element.
net处理有命名空间的xml文件的方法_xml_55
            XPathNavigator clone = nodes.Current.Clone();
net处理有命名空间的xml文件的方法_xml_55            clone.MoveToFirstChild();
net处理有命名空间的xml文件的方法_xml_55           
net处理有命名空间的xml文件的方法_xml_55           Response.Write(
string.Format("Book title: {0}", clone.Value));
net处理有命名空间的xml文件的方法_xml_55           Response.Write(
"<Br>");
net处理有命名空间的xml文件的方法_ide_62        }