I have an xml document as follows:
<?xml version="1.0" encoding="utf-8" ?>
<entityConfigur ation xmlns="http://schemas.infinit yinfo.com/entityconfigura tion"
version="1.0">
<entity name="account">
<attribute name="accountid " />
</entity>
</entityConfigura tion>
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.CreateNavig ator().Compile( "/entityConfigura tion/entity");
XmlNamespaceMan ager ns = new XmlNamespaceMan ager(new NameTable());
ns.AddNamespace ("", SchemaNamespace );
_configExpr.Set Context(ns);
// then in a method (xvr is a XmlValidatingRe ader for the above xml)
XPathDocument xpath = new XPathDocument(x vr);
XPathNavigator nav = xpath.CreateNav igator();
XPathNodeIterat or itr = nav.Select(_con figExpr); // this returns zero nodes.
Basically, the node set returned by the expression is 0. However, if I do:
XPathNodeIterat or itr = nav.SelectDesce ndants("entity" , SchemaNamespace ,
false);
Then, I will get the correct list of entity element nodes. I could also
move to entityConfigura tion node and use SelectChildren( "entity", SchemaNamespace )
with success.
Since Select is the only one that takes a compiled expression, I would like
to know why it's not working properly.
Thanks in advance.
Jiho Han
Senior Software Engineer
Infinity Info Systems
The Sales Technology Experts
Tel: 212.563.4400 x216
Fax: 212.760.0540
jhan@infinityin fo.com
<?xml version="1.0" encoding="utf-8" ?>
<entityConfigur ation xmlns="http://schemas.infinit yinfo.com/entityconfigura tion"
version="1.0">
<entity name="account">
<attribute name="accountid " />
</entity>
</entityConfigura tion>
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.CreateNavig ator().Compile( "/entityConfigura tion/entity");
XmlNamespaceMan ager ns = new XmlNamespaceMan ager(new NameTable());
ns.AddNamespace ("", SchemaNamespace );
_configExpr.Set Context(ns);
// then in a method (xvr is a XmlValidatingRe ader for the above xml)
XPathDocument xpath = new XPathDocument(x vr);
XPathNavigator nav = xpath.CreateNav igator();
XPathNodeIterat or itr = nav.Select(_con figExpr); // this returns zero nodes.
Basically, the node set returned by the expression is 0. However, if I do:
XPathNodeIterat or itr = nav.SelectDesce ndants("entity" , SchemaNamespace ,
false);
Then, I will get the correct list of entity element nodes. I could also
move to entityConfigura tion node and use SelectChildren( "entity", SchemaNamespace )
with success.
Since Select is the only one that takes a compiled expression, I would like
to know why it's not working properly.
Thanks in advance.
Jiho Han
Senior Software Engineer
Infinity Info Systems
The Sales Technology Experts
Tel: 212.563.4400 x216
Fax: 212.760.0540
jhan@infinityin fo.com
Comment