Connecting Tech Pros Worldwide Forums | Help | Site Map

XmlNode.HasChildNodes

=?Utf-8?B?QmFydCBTdGV1cg==?=
Guest
 
Posts: n/a
#1: Sep 25 '08
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





Martin Honnen
Guest
 
Posts: n/a
#2: Sep 25 '08

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