XmlNode.HasChildNodes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QmFydCBTdGV1cg==?=

    XmlNode.HasChildNodes

    I have the following issue. I'm trying to read to following XML doc.

    <Main>
    <Submain>
    <SubField1/>
    <SubField2/>
    </Submain>
    <Field1/>
    <Field2>AnyText Value</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

    #2
    Re: XmlNode.HasChil dNodes

    Bart Steur wrote:
    <Field2>AnyText Value</Field2>
    </Main>
    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

    Comment

    Working...