![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an xml document as follows: ?xml version="1.0" encoding="utf-8" ? entityConfiguration xmlns="http://schemas.infinityinfo.com/entityconfiguration" version="1.0" entity name="account" attribute name="accountid" / /entity /entityConfiguration I am trying to find all 'entity' elements to iterate and the following are the snippets: // in static constructor XmlDocument doc = new XmlDocument(); _configExpr = doc.CreateNavigator().Compile("/entityConfiguration/entity"); |
|
XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable()); ns.AddNamespace("", SchemaNamespace); |
#3
| |||
| |||
|
|
Jiho Han wrote: I have an xml document as follows: ?xml version="1.0" encoding="utf-8" ? entityConfiguration xmlns="http://schemas.infinityinfo.com/entityconfiguration" version="1.0" entity name="account" attribute name="accountid" / /entity /entityConfiguration I am trying to find all 'entity' elements to iterate and the following are the snippets: // in static constructor XmlDocument doc = new XmlDocument(); _configExpr = doc.CreateNavigator().Compile("/entityConfiguration/entity"); _configExpr = doc.CreateNavigator().Compile("/pf:entityConfiguration/pf:entity"); XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable()); ns.AddNamespace("", SchemaNamespace); ns.AddNamespace("pf", SchemaNamespace); With XPath 1.0 you always need a prefix bound to a namespace URI to select elements in that namespace, even if elements in the XML document are in a default namespace and have no prefix. You can choose the prefix as you like when you use the XPath API, and no change to the input XML is needed |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |