473,385 Members | 1,523 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,385 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 6336


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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.