Connecting Tech Pros Worldwide Help | Site Map

XmlNode.HasChildNodes

  #1  
Old September 25th, 2008, 10:35 AM
=?Utf-8?B?QmFydCBTdGV1cg==?=
Guest
 
Posts: n/a
I have the following issue. I'm trying to read to following XML doc.

<Main>
<Submain>
<SubField1/>
<SubField2/>
</Submain>
<Field1/>
<Field2>AnyTextValue</Field2>
</Main>

I loop using foreach XmlNode and testing the HasChildNodes property.

When I get to the <Submaintag the HasChildNodes property is True
When I get to the <Field1/tag the HasChildNodes property is False
so far it's clear. Then...
When I get to the <Field2tag the HasChildNodes property is True???!!!
Is it correct that the value of the <Field2node is considered a ChildNode?

Please explain.

Thks
Bart




  #2  
Old September 25th, 2008, 01:55 PM
Martin Honnen
Guest
 
Posts: n/a

re: XmlNode.HasChildNodes


Bart Steur wrote:
Quote:
<Field2>AnyTextValue</Field2>
</Main>
Quote:
When I get to the <Field2tag the HasChildNodes property is True???!!!
Is it correct that the value of the <Field2node is considered a ChildNode?
In the DOM object model (which in the .NET world
XmlDocument/XmlElement/XmlNode implement) the 'Field2' element has one
child node, a text node (instance of
http://msdn.microsoft.com/en-us/libr....xmltext.aspx). The
Value property of the 'Field2' XmlElement instance however is null in
that model. The InnerText property is 'AnyTextValue'.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why XmlNode.Name get node name and its first attribute together? =?Utf-8?B?ZGF2aWQ=?= answers 0 March 12th, 2007 06:25 PM
Help with XmlNode - node.HasChildNodes always returns true even when no child exists RJN answers 0 April 6th, 2006 07:05 PM
Help with XmlNode - HasChildNodes always returns true even no immediate child exists RJN answers 1 April 6th, 2006 07:05 PM
XMLNode.ChildNodes Venkat Venkataramanan answers 1 November 20th, 2005 01:54 AM