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 y_...@tsmc.com on 2009/05/08 09:29:17 UTC

Memeory coredump in getElementsByTagName

Hi , when i want parse xml string in my application
will coredump in getElementByTagName

xmlString sample :
In this xml string exist chinese word
<?xml version="1.0" encoding="UTF-16" standalone="no"?><Transaction><Car
ObjType="Obj_ID" Value="car1"/><memo ObjType="claimMemo">@DIF||編號
</memo></Transaction>

sample code :

try
{
      DOMNodeList * nodelist  =
root->getElementsByTagName(XMLString::transcode("Car")) ;   --->> this will
coredump
in my application can't get any exception !!!
}
 catch( const DOMException& exception)
 {
         char * message = XMLString::transcode(exception.getMessage());
          cout << message << endl;
          XMLString::release(&message);
          return 1 ;
        }
        catch( const XMLException& exception)
        {
            char * message = XMLString::transcode(exception.getMessage());
               cout << message << endl;
            XMLString::release(&message);
            return 1 ;
        }
        catch( const SAXException& exception)
        {
            char * message = XMLString::transcode(exception.getMessage());
               cout << message << endl;
            XMLString::release(&message);
            return 1 ;
        }
        catch (...)
        {
            cout << " catch ... " << endl ;
            return 1 ;
        }





 --------------------------------------------------------------------------- 
                                                         TSMC PROPERTY       
 This email communication (and any attachments) is proprietary information   
 for the sole use of its                                                     
 intended recipient. Any unauthorized review, use or distribution by anyone  
 other than the intended                                                     
 recipient is strictly prohibited.  If you are not the intended recipient,   
 please notify the sender by                                                 
 replying to this email, and then delete this email and any copies of it     
 immediately. Thank you.                                                     
 --------------------------------------------------------------------------- 


Re: Memeory coredump in getElementsByTagName

Posted by David Bertoni <db...@apache.org>.
y_tzeng@tsmc.com wrote:
> Hi , when i want parse xml string in my application
> will coredump in getElementByTagName
> 
> xmlString sample :
> In this xml string exist chinese word
> <?xml version="1.0" encoding="UTF-16" standalone="no"?><Transaction><Car
> ObjType="Obj_ID" Value="car1"/><memo ObjType="claimMemo">@DIF||編號
> </memo></Transaction>
> 
> sample code :
> 
> try
> {
>       DOMNodeList * nodelist  =
> root->getElementsByTagName(XMLString::transcode("Car")) ;   --->> this will
> coredump
> in my application can't get any exception !!!
Do not use XMLString::transcode(), because it relies on the local code page.

If you need to use constant strings like this in your application,
create UTF-16 strings, such as you'll find in util/XMLUni.cpp:

const XMLCh XMLUni::fgAnyString[] =
{
    chLatin_A, chLatin_N, chLatin_Y, chNull
};

Dave

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


Re: Memeory coredump in getElementsByTagName

Posted by Alberto Massari <am...@datadirect.com>.
Have you checked if root is a NULL pointer? Maybe the parsing failed
because that chinese word is not written using a correct UTF-16 string...

Alberto

y_tzeng@tsmc.com ha scritto:
> Hi , when i want parse xml string in my application
> will coredump in getElementByTagName
>
> xmlString sample :
> In this xml string exist chinese word
> <?xml version="1.0" encoding="UTF-16" standalone="no"?><Transaction><Car
> ObjType="Obj_ID" Value="car1"/><memo ObjType="claimMemo">@DIF||編號
> </memo></Transaction>
>
> sample code :
>
> try
> {
>       DOMNodeList * nodelist  =
> root->getElementsByTagName(XMLString::transcode("Car")) ;   --->> this will
> coredump
> in my application can't get any exception !!!
> }
>  catch( const DOMException& exception)
>  {
>          char * message = XMLString::transcode(exception.getMessage());
>           cout << message << endl;
>           XMLString::release(&message);
>           return 1 ;
>         }
>         catch( const XMLException& exception)
>         {
>             char * message = XMLString::transcode(exception.getMessage());
>                cout << message << endl;
>             XMLString::release(&message);
>             return 1 ;
>         }
>         catch( const SAXException& exception)
>         {
>             char * message = XMLString::transcode(exception.getMessage());
>                cout << message << endl;
>             XMLString::release(&message);
>             return 1 ;
>         }
>         catch (...)
>         {
>             cout << " catch ... " << endl ;
>             return 1 ;
>         }
>
>
>
>
>
>  --------------------------------------------------------------------------- 
>                                                          TSMC PROPERTY       
>  This email communication (and any attachments) is proprietary information   
>  for the sole use of its                                                     
>  intended recipient. Any unauthorized review, use or distribution by anyone  
>  other than the intended                                                     
>  recipient is strictly prohibited.  If you are not the intended recipient,   
>  please notify the sender by                                                 
>  replying to this email, and then delete this email and any copies of it     
>  immediately. Thank you.                                                     
>  --------------------------------------------------------------------------- 
>
>   


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