XML文件格式为:<?xml version="1.0" encoding="utf-16"?>
<DECDataSet xmlns="http://tempuri.org/DECDataSet.xsd">
.........想读取 <DECDataSet 根节点,获取所有子结点,读取方法为:
xmlDoc.Load(xmlDocStr); XmlNodeList nodeList = xmlDoc.SelectSingleNode("DECDataSet").ChildNodes;第二句报错,请高手给出建议,谢谢
<DECDataSet xmlns="http://tempuri.org/DECDataSet.xsd">
.........想读取 <DECDataSet 根节点,获取所有子结点,读取方法为:
xmlDoc.Load(xmlDocStr); XmlNodeList nodeList = xmlDoc.SelectSingleNode("DECDataSet").ChildNodes;第二句报错,请高手给出建议,谢谢
要指定命名空间 xmlDoc.Load(xmlDocStr);
XmlNamespaceManager m = new XmlNamespaceManager(xmlDoc.NameTable);
m.AddNamespace("aa", "http://tempuri.org/DECDataSet.xsd");
XmlNodeList nodeList = xmlDoc.SelectSingleNode("aa:DECDataSet", m).ChildNodes;