473,413 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 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 6339


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: David Thielen | last post by:
Hi; I have an element: <space> </space> When I call SelectSingleNode() on it, the InnerXml is a 0 length String, not a String containing 1 space. Any ideas?
4
by: Jack Fox | last post by:
I'm navigating through a XPathDocument consisting of mostly mixed complex type elements (i.e. innertext plus more elements). When I use XPathNavigator.Value to retrieve the text I get everything...
1
by: SteZgr | last post by:
I have implemented in .NET 2.0 a custom XPathNavigator for Xpath filtering on an object tree. So far it works. While analyzing the performance, I have noticed a lot of MoveToNextAttribute calls. ...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
2
by: Jiho Han | last post by:
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...
0
by: kelvin273 | last post by:
Hi all, i'm new in this community (and in .NET programming) and i've a problem with xpathnavigator. The idea is to have an xml document with attribute editable by windows form. I write this...
2
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
Hi. Using VS2005, .NET 2.0. I have an xml document that I want to go through and set the values on attributes of elements. The elements are complex types defined in my schema (xsd) files. ...
1
by: WestyCHC | last post by:
Morning all from a newbie. I have recently written an automation program (my first ever program) for testing and now I am trying to read XML data and assign the values to variables (rather than...
2
by: =?Utf-8?B?QXJuZQ==?= | last post by:
I use XpathNavigator ut process the XML data I get from a web service. I know how to select a specific node. How Do I pick of the attribute of a node?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.