473,224 Members | 1,504 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,224 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 6320


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?
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.