You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Nicole <sp...@yahoo.com> on 2001/08/09 15:40:36 UTC

Getting Content Between Tags

Hi,

This is probably considered a newbie question, but I'd
really appreciate any help I can get.  

I don't know how to extract the values between XML
tags.  I can see that getNodeValue doesn't do the
trick, and I remember reading in the mail archive that
it always returns null for element tags.   Is there a
way to do this?

Thanks in advance,
Nicole



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Getting Content Between Tags

Posted by Nicole <sp...@yahoo.com>.
Thank you Alberto and Joseph for getting me on the
right track!  I just worked the code you provided into
my existing code, and I'm getting good results!

Nicole

--- Alberto Massari <al...@exceloncorp.com> wrote:
> At 06.40 09/08/2001 -0700, you wrote:
> >Hi,
> >
> >This is probably considered a newbie question, but
> I'd
> >really appreciate any help I can get.
> >
> >I don't know how to extract the values between XML
> >tags.  I can see that getNodeValue doesn't do the
> >trick, and I remember reading in the mail archive
> that
> >it always returns null for element tags.   Is there
> a
> >way to do this?
> 
> Hi Nicole,
> You need to walk down to the children of the element
> node and invoke 
> getNodeValue on the text node. Something like that
> (if you know that you 
> can have only simple string - no child tags -
> between the XML tags):
> 
>              DOM_Node child =
> element.getFirstChild();
>              while( child != 0)
>              {
>                 
> if(child.getNodeType()==DOM_Node::TEXT_NODE)
>                      return child.getNodeValue();
>                  child = child.getNextSibling();
>              }
> 
> Alberto
> 
> -------------------------------
> Alberto Massari
> eXcelon Corp.
> http://www.StylusStudio.com
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-c-dev-help@xml.apache.org
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Getting Content Between Tags

Posted by Alberto Massari <al...@exceloncorp.com>.
At 06.40 09/08/2001 -0700, you wrote:
>Hi,
>
>This is probably considered a newbie question, but I'd
>really appreciate any help I can get.
>
>I don't know how to extract the values between XML
>tags.  I can see that getNodeValue doesn't do the
>trick, and I remember reading in the mail archive that
>it always returns null for element tags.   Is there a
>way to do this?

Hi Nicole,
You need to walk down to the children of the element node and invoke 
getNodeValue on the text node. Something like that (if you know that you 
can have only simple string - no child tags - between the XML tags):

             DOM_Node child = element.getFirstChild();
             while( child != 0)
             {
                 if(child.getNodeType()==DOM_Node::TEXT_NODE)
                     return child.getNodeValue();
                 child = child.getNextSibling();
             }

Alberto

-------------------------------
Alberto Massari
eXcelon Corp.
http://www.StylusStudio.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org