xml的查找
我想通过下列语句来读取xml中的数据,
可是foo的值总是为空
//……
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
xmlDocument.Load("d:\\xmlfoo.XML");
System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(xmlDocument.NameTable);
nsmgr.AddNamespace(String.Empty,"http://tempuri.org/SPThemes.xsd");
System.Xml.XmlElement root = xmlDocument.DocumentElement;
System.Xml.XmlNodeList foo = root.SelectNodes (String.Format("//Templates"),nsmgr);
//……
xmlfoo.XML:
<?xml version="1.0" encoding="utf-8" ?>
<SPThemes xmlns="http://tempuri.org/SPThemes.xsd">
<Templates>
<TemplateID>none</TemplateID>
<DisplayName>No Theme(Default)</DisplayName>
<Description>Description</Description>
<Thumbnail>../images/thnone.png</Thumbnail>
<Preview>../images/thnone.gif</Preview>
</Templates>
<Templates>
<TemplateID>aftrnoon</TemplateID>
<DisplayName>Afternoon</DisplayName>
<Description>Description</Description>
<Thumbnail>../images/thanoon.png</Thumbnail>
<Preview>../images/thanoon.gif</Preview>
</Templates>
</SPThemes>