xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@progress.com>
Subject Re: question about QElement::getElementsByTagName()
Date Mon, 08 Mar 2004 13:29:38 GMT
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: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Mime
View raw message