本人新手。求大牛帮忙读下xml文件。具体格式如下
- XML code
<?xml version="1.0" encoding="GB2312"?><rdf:RDF xmlns:cimIESLAB="http://ieslab.com.cn/CIM/ext-schema#" xmlns:cim="http://iec.ch/TC57/2003/CIM-schema-cim10#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ><cim:Company rdf:ID="c_1" > <cim:Naming.description>公司</cim:Naming.description> <cim:Naming.name>枣庄电网</cim:Naming.name></cim:Company><cim:SubControlArea rdf:ID="a_市中" > <cim:Naming.description>市中</cim:Naming.description> <cim:Naming.name>市中</cim:Naming.name> <cim:PowerSystemResource.OperatedBy_Companies rdf:resource="#c_1" /></cim:SubControlArea><cim:SubControlArea rdf:ID="a_峄城" > <cim:Naming.description>峄城</cim:Naming.description> <cim:Naming.name>峄城</cim:Naming.name> <cim:PowerSystemResource.OperatedBy_Companies rdf:resource="#c_1" /></cim:SubControlArea><cim:SubControlArea rdf:ID="a_山亭" > <cim:Naming.description>山亭</cim:Naming.description> <cim:Naming.name>山亭</cim:Naming.name> <cim:PowerSystemResource.OperatedBy_Companies rdf:resource="#c_1" /></cim:SubControlArea><cim:SubControlArea rdf:ID="a_台儿庄" > <cim:Naming.description>台儿庄</cim:Naming.description> <cim:Naming.name>台儿庄</cim:Naming.name> <cim:PowerSystemResource.OperatedBy_Companies rdf:resource="#c_1" /></cim:SubControlArea><cim:SubControlArea rdf:ID="a_薛城" > <cim:Naming.description>薛城</cim:Naming.description> <cim:Naming.name>薛城</cim:Naming.name> <cim:PowerSystemResource.OperatedBy_Companies rdf:resource="#c_1" /></cim:SubControlArea><cim:SubControlArea rdf:ID="a_滕州" > <cim:Naming.description>滕州</cim:Naming.description> <cim:Naming.name>滕州</cim:Naming.name> <cim:PowerSystemResource.OperatedBy_Companies rdf:resource="#c_1" /></cim:SubControlArea></rdf:RDF>
主要读 cim:SubControlArea rdf:ID
cim:Naming.description
cim:Naming.name
cim:PowerSystemResource.OperatedBy_Companies rdf:resource=
------解决方案--------------------------------------------------------
- C# code
XmlDocument d = new XmlDocument();d.Load(Server.MapPath("~/1.xml"));XmlNamespaceManager nmr = new XmlNamespaceManager(d.NameTable);nmr.AddNamespace("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");nmr.AddNamespace("cim","http://iec.ch/TC57/2003/CIM-schema-cim10#");XmlNodeList SubControlArea = d.SelectNodes("/rdf:RDF/cim:SubControlArea", nmr);foreach (XmlNode n in SubControlArea){ XmlNode desc = n.SelectSingleNode("cim:Naming.name", nmr); Response.Write("<li>rdf:ID=" + n.Attributes["rdf:ID"].Value + " cim:Naming.name=" + desc.InnerText);}