Text Content in 3W DOM Element

Discussion in 'Java' started by RC, Aug 6, 2008.

  1. RC

    RC Guest

    If I have a XML file like

    <header>
    <data>1.0</data>
    </header>

    In the header element getTextContent() why it return
    1.0? Shouldn't it return null?
    In the data element getTextContent() should return 1.0, right?
    RC, Aug 6, 2008
    #1
    1. Advertising

  2. RC

    Arne Vajhøj Guest

    RC wrote:
    > If I have a XML file like
    >
    > <header>
    > <data>1.0</data>
    > </header>
    >
    > In the header element getTextContent() why it return
    > 1.0? Shouldn't it return null?
    > In the data element getTextContent() should return 1.0, right?


    No.

    Docs say:

    "This attribute returns the text content of this node and its descendants."

    It takes all text for element and all elements below it.

    Arne
    Arne Vajhøj, Aug 7, 2008
    #2
    1. Advertising

  3. RC wrote:
    > If I have a XML file like
    >
    > <header>
    > <data>1.0</data>
    > </header>
    >
    > In the header element getTextContent() why it return
    > 1.0? Shouldn't it return null?
    > In the data element getTextContent() should return 1.0, right?


    The javadoc starts with "This attribute returns the text content of this
    node and its descendants.".

    --
    Roger Lindsjö
    Roger Lindsjö, Aug 27, 2008
    #3
  4. Roger Lindsjö wrote:
    > The javadoc starts with "This attribute returns the text content of this
    > node and its descendants.".


    Oops, didn't see the other (almost identical) answer.

    --
    Roger Lindsjö
    Roger Lindsjö, Aug 27, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hazz
    Replies:
    6
    Views:
    49,548
    SkyUCHC
    Jun 9, 2010
  2. Ian Wilson
    Replies:
    2
    Views:
    552
    Ian Wilson
    Jul 26, 2007
  3. HANM
    Replies:
    2
    Views:
    708
    Joseph Kesselman
    Jan 29, 2008
  4. ted benedict
    Replies:
    3
    Views:
    144
  5. david.karr
    Replies:
    4
    Views:
    212
Loading...

Share This Page