解析带命名空间的xml文件

void Doc()
{
XmlDocument doc = new XmlDocument();
doc.Load(AppDomain.CurrentDomain.BaseDirectory + "File.xml");
XmlNode node = doc.DocumentElement;

//加入命名空间
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("cim", "http://ns.zhaopin.com/resumes");

XmlNodeList xnl = node.SelectSingleNode("//cim:Resume", nsmgr).ChildNodes;
StringBuilder sb = new StringBuilder();
int i = 0;
foreach (XmlNode item inxnl)
xml version="1.0" encoding="utf-8"?>
<cim:Resume xmlns:cim="http://ns.zhaopin.com/resumes" xmlns:rdf="a">
<cim:Breaker rdf:ID="_Breaker_abc5011" >
<cim:Naming.aliasName>abc5011cim:Naming.aliasName>
<cim:Naming.name>abc5011cim:Naming.name>
<cim:Switch.normalOpen>1cim:Switch.normalOpen>
<cim:Breaker.ampRating>0.0000cim:Breaker.ampRating>
<cim:Equipment.MemberOf_EquipmentContainer rdf:resource="#_VoltageLevel_abc500"/>
<cim:ConductingEquipment.Terminals rdf:resource="#_Terminal_cb1_T1"/>
<cim:ConductingEquipment.Terminals rdf:resource="#_Terminal_cb1_T2"/>
cim:Breaker>
<cim:BusbarSection rdf:ID="_BusbarSection_abc5b1">
<cim:Naming.aliasName>二电厂1母cim:Naming.aliasName>
<cim:Naming.name>abc5b1cim:Naming.name>
<cim:Equipment.MemberOf_EquipmentContainer rdf:resource="#_VoltageLevel_abc500"/>
<cim:ConductingEquipment.Terminals rdf:resource="#_Terminal_bus1_T1"/>
cim:BusbarSection>
cim:Resume>


转载于:https://www.cnblogs.com/cyccess/archive/2012/02/07/2341518.html

你可能感兴趣的:(解析带命名空间的xml文件)