XML遭遇缺省Namespace
缺省命名空间也要定义名字,并使用它。
reference: http://support.microsoft.com/kb/318545/zh-cn
Log.ShowMsg("Load {0}",dataFile);
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(dataFile);
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(dataFile);
XmlNamespaceManager nm=new XmlNamespaceManager(xmlDoc.NameTable);
nm.AddNamespace("c","http://tempuri.org/Cingular Service Plan.xsd");
nm.AddNamespace("c","http://tempuri.org/Cingular Service Plan.xsd");
XmlElement rootNode=xmlDoc.DocumentElement;
XmlNodeList list=rootNode.SelectNodes("/c:CINGULAR/c:CINGULARCATALOG/c:CATALOG/c:NATIONS",nm);
Console.WriteLine("Count:"+list.Count.ToString());
XmlNodeList list=rootNode.SelectNodes("/c:CINGULAR/c:CINGULARCATALOG/c:CATALOG/c:NATIONS",nm);
Console.WriteLine("Count:"+list.Count.ToString());