Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 5th, 2006, 06:15 AM
Keith Patrick
Guest
 
Posts: n/a
Default 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?


  #2  
Old August 5th, 2006, 01:05 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: XPathNavigator.SelectChildren(XPathNodeType.Attrib ute) doesn'twork?



Keith Patrick wrote:
Quote:
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/
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles