471,123 Members | 869 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

XPathNavigator.SelectChildren(XPathNodeType.Attrib ute) doesn't work?

I'm converting over from using XmlNodes (specifically ConfigXmlNode, but the
API uses XmlNode) to IXPathNavigable in some methods I have, but I'm finding
in the process, that I can't seem to get the attributes. If I have some
XML:

<ApplicationConfiguration Test="Blahblah"
AnotherAttr="asdfasd">

And I have the code:

XPathNavigator navigator = node.CreateNavigator();
XPathNodeIterator child =
navigator.SelectChildren(XPathNodeType.Attribute);

foreach (Object child in
navigator.SelectChildren(XPathNodeType.Attribute))
{
System.Diagnostics.Debug.WriteLine(child.ToString( ));
}

But the child count is always 0. If I change to XPathNodeType.All, I will
enumerate through the child elements, but again, the attributes don't show
up. Is this correct behavior, a bug, or am I misusing IXPathNavigable?
Aug 5 '06 #1
1 6200


Keith Patrick wrote:
I'm converting over from using XmlNodes (specifically ConfigXmlNode, but the
API uses XmlNode) to IXPathNavigable in some methods I have, but I'm finding
in the process, that I can't seem to get the attributes. If I have some
XML:

<ApplicationConfiguration Test="Blahblah"
AnotherAttr="asdfasd">

And I have the code:

XPathNavigator navigator = node.CreateNavigator();
XPathNodeIterator child =
navigator.SelectChildren(XPathNodeType.Attribute);
Attribute nodes are not children of an element node, neither in the DOM
data model nor in the XPath data model. Use MoveToFirstAttribute and
MoveToNextAttribute if you want to iterate over attributes with an
XPathNavigator.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jack Fox | last post: by
2 posts views Thread by =?Utf-8?B?Tm9yZW1hYw==?= | last post: by
2 posts views Thread by =?Utf-8?B?QXJuZQ==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.