<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的值呢
如果能将命名空间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);