biswanath_c has asked for the wisdom of the Perl Monks concerning the following question:


Hi,

I was trying to parse an XML doc using XML::LibXML package... I was trying to use textContent() method on a node element to get a node's value. But it gave me the node's value ALONG WITH THE child's value and the grandchild's value!!

What method should i use if i want only the current node's value and NOT the children's value?!


  • Comment on textContent() method in XML::LibXML ...

Replies are listed 'Best First'.
Re: textContent() method in XML::LibXML ...
by ramrod (Priest) on Oct 15, 2009 at 21:01 UTC
    According to the libXML documentation this is what I would expect.

    Try nodeValue.
    Or maybe use a different Xpath along with the XML::LibXML::Text module.

    As with some of your more recent posts, we could help you out more with a sample of the xml, and the xpath you are trying.

      nodeValue() worked! Thanks a lot!! That was VERY helpful! nodeValue() just picks the value of the current node. textCOntent() collates the values of the node and all its children and it's children's children and so on until the leaf is reached!!!

      Thanks again!


        I am trying with nodeValue() it not working