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 David --- <da...@yahoo.fr> on 2004/03/15 12:59:34 UTC
Dom parser problem with transcode
Hi,
I'm having a problem building a Domparser.
The code below run properly qnd after debugging it
exits normally as well.
It seems the problem comes from the transcode method.
If i remove the transcode it returns the corresponding
encoded value but like that it return nothing and it
dies after i call the transcode method.
for( std::vector<std::string>::iterator tag =
tags.begin(); tag !=tags.end(); tag++)
{
char *query = strdup((*tag).c_str());
XMLCh* tmpstr = XMLString::transcode(query);
int len;
c_nodelist = c_doc->getElementsByTagName(tmpstr);
len = c_nodelist->getLength();
std::cout << "LEN " << len << std::endl;
for (int i = 0 ; i < len ; i++)
{
c_node = c_nodelist->item(i);
const XMLCh* val = c_node->getNodeValue();
char *test = XMLString::transcode(val);
std::cout <<"Val: " <<
XMLString::transcode(val);
}
}
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Dom parser problem with transcode
Posted by Gareth Reakes <pa...@parthenoncomputing.com>.
Hi,
are you aware that getNodeValue on an element returns NULL?
Gareth
--
Gareth Reakes, Managing Director +44-1865-811184
Parthenon Computing http://www.parthcomp.com
On Mon, 15 Mar 2004, [iso-8859-1] David --- wrote:
>
> Hi,
> I'm having a problem building a Domparser.
> The code below run properly qnd after debugging it
> exits normally as well.
>
> It seems the problem comes from the transcode method.
> If i remove the transcode it returns the corresponding
> encoded value but like that it return nothing and it
> dies after i call the transcode method.
>
> for( std::vector<std::string>::iterator tag =
> tags.begin(); tag !=tags.end(); tag++)
> {
> char *query = strdup((*tag).c_str());
> XMLCh* tmpstr = XMLString::transcode(query);
>
> int len;
> c_nodelist = c_doc->getElementsByTagName(tmpstr);
> len = c_nodelist->getLength();
> std::cout << "LEN " << len << std::endl;
> for (int i = 0 ; i < len ; i++)
> {
> c_node = c_nodelist->item(i);
> const XMLCh* val = c_node->getNodeValue();
> char *test = XMLString::transcode(val);
> std::cout <<"Val: " <<
> XMLString::transcode(val);
> }
>
>
>
> }
>
>
>
>
>
>
>
>
>
>
>
> Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
> Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
>
> Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Dom parser problem with transcode
Posted by Alberto Massari <am...@progress.com>.
At 12.59 15/03/2004 +0100, you wrote:
>Hi,
>I'm having a problem building a Domparser.
>The code below run properly qnd after debugging it
>exits normally as well.
>
>It seems the problem comes from the transcode method.
>If i remove the transcode it returns the corresponding
>encoded value but like that it return nothing and it
>dies after i call the transcode method.
>
> for( std::vector<std::string>::iterator tag =
>tags.begin(); tag !=tags.end(); tag++)
> {
> char *query = strdup((*tag).c_str());
> XMLCh* tmpstr = XMLString::transcode(query);
>
> int len;
> c_nodelist = c_doc->getElementsByTagName(tmpstr);
> len = c_nodelist->getLength();
> std::cout << "LEN " << len << std::endl;
> for (int i = 0 ; i < len ; i++)
> {
> c_node = c_nodelist->item(i);
> const XMLCh* val = c_node->getNodeValue();
> char *test = XMLString::transcode(val);
> std::cout <<"Val: " <<
>XMLString::transcode(val);
> }
You are calling getNodeValue() on a DOMElement node, and this method will
always return NULL in this case; I guess what you really want to do is
invoke getTextContent()
Alberto
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org