Alberto Massari wrote:
> Hi Peter,
>
> At 14.24 08/03/2004 +0100, Peter Billen wrote:
> >Hi all,
> >
> >I have a question about the getElementsByTagName()-function.
> >
> >Imagine following simple xml structure:
> >
> ><bla>
> > <huh>woezaa</huh>
> ></bla>
> >
> >I'm using DOM to parse the file. But why is the following printing 'huh'
> and
> >not 'woezaa', when I'm currently in <bla>?
> >
> >if (strcmp(currentNode->getNodeName(), "bla") == 0)
> >{
> > DOMText* nodeLocation = (DOMText*) (((DOMElement*)
> >currentNode)->getElementsByTagName(XMLString::transcode("huh"))-
> >item(0));
> >
> > cout << XMLString::transcode(nodeLocation->getData());
> >}
>
> getElementsByTagName returns a list of elements having the specified name;
> item(0) will get you the first in the list (that is, "huh"). If you want
> to
> get the DOMText that contains "woezaa" you need to change it to be
> item(0)->getFirstChild()
>
> Alberto
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
Ah yes, ofcourse! Stupid I didn't notice that.
Thanks a lot Alberto,
--
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]