Hello,

Gareth Reakes, Lead Software Engineer  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192


On Fri, 23 Mar 2001, Alex Fridman wrote:

> Hi,
> 
> I have a technical question.
> 
> I am using the DOMParser to parse the xml file.  It parses the file and
> builds the DOM_Document just fine. It also works when I ask for any node in
> the tree, but for some reason it fails when I call getNodeValue() function
> to get the value of the node, although the node definitely has a value in my
> file.
> 
> This is the peace of code that's failing
>       DOM_Document document=parser->getDocument();
>       DOM_NodeList iqList=document.getElementsByTagName("iq");
>       if(iqList.getLength()){
>               DOM_Node iqTag=iqList.item(0);
>               DOM_NamedNodeMap iqAtt=iqTag.getAttributes();
>               DOM_Node type=iqAtt.getNamedItem("type");
>               cout << "Type " + String(type.getNodeValue().transcode()) <<
> endl;
>               if(String(type.getNodeValue().transcode()) == "error"){
>                       DOM_NodeList
> errorList=document.getElementsByTagName("error");
>                       if(errorList.getLength()){
>                               DOM_Node errorTag=errorList.item(0);
>                               DOM_NamedNodeMap
> errorAtt=errorTag.getAttributes();
>                               DOM_Node code=errorAtt.getNamedItem("code");
>                               cout << errorTag.getNodename().transcode()
> << endl; //this works
>                               cout << errorTag.getNodeValue().transcode()
> << endl; //this does not

This would not work as DOM_Element Nodes do not have a node value. If you
are trying to print out the contents then look at the DOMSerialize
example.

hope this helps,

Gareth



>                               cout << code.getNodeValue().transcode() <<
> endl;
>                               throw Exception("Code " +
> String(code.getNodeValue().transcode()) + " Message "+ String
> (errorTag.getNodeValue().transcode()));
>                       }else{
>                               throw Exception("Invalid register responce
> from the server");    
>                       }
>               }
>       }else{
>               throw Exception("Invalid register responce from the
> server");     
>       }
> 
> Thanks,
> Alex Fridman
> Automated Financial Systems
> (212)771-1923 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to