首页 新闻 会员 周边

利用xpath如何读取以下节点的属性值

0
[已解决问题] 解决于 2013-04-15 15:26
<ConfigEntities xmlns="http://iittd.com/ServiceConfigurationSchema.xsd">
<ServiceInstance AssemblyPath="D:\WorkingDir\Agspan\Benchmark\agspanadvantage\services\EKS Gatekeeper Service\Instance\EKSThirdPartyFeedstuffsDataCollection\EKS.FeedStuffsDataCollection.WindowsService.dll" MainClass="EKS.FeedStuffsDataCollection.WindowsService.Gatekeeper" Enabled="true" Description="Feedstuffs data collection" />
</<ConfigEntities >

如何读取节点ServiceInstance的AssemblyPath、MainClass、Enabled、Description的值呢

xml
阿磊ing的主页 阿磊ing | 初学一级 | 园豆:2
提问于:2013-03-29 10:02
< >
分享
最佳答案
0

如果能将命名空间xmlns=http://iittd.com/ServiceConfigurationSchema.xsd删除,那么XPtah就非常简单,就是“/ConfigEntities/ServiceInstance”,然后检索得到的XMLNode的Attributes,例如Attributes["AssemblyPath"]。

如果不能删除这个自定义的命名空间,那么你要加上命名空间的信息XmlNamespaceManager nsmgr =newXmlNamespaceManager(xml.NameTable);nsmgr.AddNamespace("x","xmlns=http://iittd.com/ServiceConfigurationSchema.xsd"); xmlNode.SelectSingleNode("/ConfigEntities/ServiceInstance", nsmgr);

奖励园豆:5
Luke Zhang | 菜鸟二级 |园豆:293 | 2013-03-29 12:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册