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 "Oswin, Stephen" <St...@AbbeyNational.co.uk> on 2001/01/11 21:24:14 UTC

getNodeValue() is blank, but getNodeName() works

bit lame I know, but I cant get anything when I call getNodeValue() on a
DOM_Node. getNodeName() works fine. Is there something else I should be
doing? I'm running ver 1.3.0 on Solaris.

Any help appreciated.

thanks

Stephen Oswin

Code:

input XML:

	<Data number="0">
		<SOMEID>23748</SOMEID>
		<SOMETYPE>4</SOMETYPE>
	</Data>

...
...
for( int lp=0; lp < num_nodes; lp++ )
{
	pNodeName  = dmlMWDElements.item(lp).getNodeName().transcode();
	pNodeValue = dmlMWDElements.item(lp).getNodeValue().transcode();

	fprintf(stdout, "\nnode type=[%d] name=[%s] value=[%s]", (int)
dmlMWDElements.item(lp).getNodeType(), pNodeName, pNodeValue );

	delete []pNodeName;
	delete []pNodeValue;
}




Important:

Internet communications are not necessarily secure and may be intercepted or changed after they are sent.
The Abbey National Group does not accept liability for any such changes. If you wish to confirm the origin or content of this communication, please contact the sender using an alternative means of communication.

This communication does not create or modify any contract.

If you are not the intended recipient of this communication you should destroy it without copying, disclosing or otherwise using its contents. Please notify the sender immediately of the error.

The Abbey National Group comprises Abbey National plc and its subsidiary group of companies.

Abbey National plc. Registered Office: Abbey House, Baker Street, London, NW1 6XL. Reg. No. 2294747.
Registered in England.

Re: getNodeValue() is blank, but getNodeName() works

Posted by Khaled Noaman <kn...@ca.ibm.com>.
To obtain the text content of DOM_Node, you need to check its children for Text nodes, then call getNodeValue on the Text node. Take a look at the DOMPrint sample for an example.

Regards,
Khaled Noaman
XML Parsers - IBM Toronto Dev.
knoaman@ca.ibm.com

"Oswin, Stephen" wrote:

> bit lame I know, but I cant get anything when I call getNodeValue() on a
> DOM_Node. getNodeName() works fine. Is there something else I should be
> doing? I'm running ver 1.3.0 on Solaris.
>
> Any help appreciated.
>
> thanks
>
> Stephen Oswin
>
> Code:
>
> input XML:
>
>         <Data number="0">
>                 <SOMEID>23748</SOMEID>
>                 <SOMETYPE>4</SOMETYPE>
>         </Data>
>
> ...
> ...
> for( int lp=0; lp < num_nodes; lp++ )
> {
>         pNodeName  = dmlMWDElements.item(lp).getNodeName().transcode();
>         pNodeValue = dmlMWDElements.item(lp).getNodeValue().transcode();
>
>         fprintf(stdout, "\nnode type=[%d] name=[%s] value=[%s]", (int)
> dmlMWDElements.item(lp).getNodeType(), pNodeName, pNodeValue );
>
>         delete []pNodeName;
>         delete []pNodeValue;
> }
>
> Important:
>
> Internet communications are not necessarily secure and may be intercepted or changed after they are sent.
> The Abbey National Group does not accept liability for any such changes. If you wish to confirm the origin or content of this communication, please contact the sender using an alternative means of communication.
>
> This communication does not create or modify any contract.
>
> If you are not the intended recipient of this communication you should destroy it without copying, disclosing or otherwise using its contents. Please notify the sender immediately of the error.
>
> The Abbey National Group comprises Abbey National plc and its subsidiary group of companies.
>
> Abbey National plc. Registered Office: Abbey House, Baker Street, London, NW1 6XL. Reg. No. 2294747.
> Registered in England.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org