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 Martin Bosticky <mb...@aimltd.co.uk> on 2002/10/24 10:58:27 UTC

getNodeValue() doesn't work?

Hello. The way I apply my code means that getNodeValue() on DOMElement
does not work correctly!
 
I have just joined the mailing group and done some search in bugzilla to
see if this is a known bug or what is going on?
 
I am using xercesc 2.1.0 in C++ and the code and my XML are very
trivial:
 
Alfter parsing the document I get the top element and from that an
element that I am interested in:
 
DOMNodeList* node =
docElement->getElementsByTagName(XMLString::transcode("Url"));
                                    DOMNode* el = (node->item(0));
                                    std::string vl_Child1_str =
CreateString(el->getNodeName());
                                    std::string vl_Url_str =
CreateString(el->getNodeValue());
 
The node 'el' that I obtain has the correct node name and so I try to
get the node value which should be text. But getNodeValue() returns a
null pointer.
 
**********************************************************
I checked the source code and discovered that it seems like the
DOMNodeImpl class has the function as a virtual function but the derived
object DOMElementImpl never overrides this so you will always get a null
pointer no matter what.
**********************************************************
 
I have tested my XML by putting the desired url string into an attribute
and then I can easily retrieve it using getAttributes() etc.
 
Bugzilla didn't turn up anything that was up to date. Is this problem
known?
Should I do parsing another way that would work?
Is version 2.1.0 full of bugs and I should not be using it?
What to do?
 
Any comments would be appreciated, Martin.
 
Martin Bosticky
Software Engineer
Action Information Management Ltd.
Tel: (01225) 711200
Fax: (01225) 711222
Email: mbosticky@aimltd.co.uk
 



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


Re: getNodeValue() doesn't work?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	the behaviour you are seeing is correct. Look at the docs for 
DOMNode where the return value for each of the node types is shown.

Gareth


On Thu, 24 Oct 2002, Martin Bosticky wrote:

> Hello. The way I apply my code means that getNodeValue() on DOMElement
> does not work correctly!
>  
> I have just joined the mailing group and done some search in bugzilla to
> see if this is a known bug or what is going on?
>  
> I am using xercesc 2.1.0 in C++ and the code and my XML are very
> trivial:
>  
> Alfter parsing the document I get the top element and from that an
> element that I am interested in:
>  
> DOMNodeList* node =
> docElement->getElementsByTagName(XMLString::transcode("Url"));
>                                     DOMNode* el = (node->item(0));
>                                     std::string vl_Child1_str =
> CreateString(el->getNodeName());
>                                     std::string vl_Url_str =
> CreateString(el->getNodeValue());
>  
> The node 'el' that I obtain has the correct node name and so I try to
> get the node value which should be text. But getNodeValue() returns a
> null pointer.
>  
> **********************************************************
> I checked the source code and discovered that it seems like the
> DOMNodeImpl class has the function as a virtual function but the derived
> object DOMElementImpl never overrides this so you will always get a null
> pointer no matter what.
> **********************************************************
>  
> I have tested my XML by putting the desired url string into an attribute
> and then I can easily retrieve it using getAttributes() etc.
>  
> Bugzilla didn't turn up anything that was up to date. Is this problem
> known?
> Should I do parsing another way that would work?
> Is version 2.1.0 full of bugs and I should not be using it?
> What to do?
>  
> Any comments would be appreciated, Martin.
>  
> Martin Bosticky
> Software Engineer
> Action Information Management Ltd.
> Tel: (01225) 711200
> Fax: (01225) 711222
> Email: mbosticky@aimltd.co.uk
>  
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



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