xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@datadirect.com>
Subject Re: DOMLSSerializer converts white space characters in attributes to xml entities
Date Thu, 30 Jul 2009 15:37:47 GMT
No, if the serialized attribute value has newlines/tab, they are 
converted upon loading into spaces. If you want to really store such 
characters in an attribute, they have to be encoded into entities.

Alberto

mini thomas wrote:
> Hi,
>  
> I am using xerces 3.0.1 and doing the following
>  
>
> 1) Parse a string
>  
> 2)Set an attribute "newattr" on the root node. The attribute value is 
> char *temp = "\n Hello \t\t testing"
>  
> 3) converting the parsed data back to xml
>  
> static const XMLCh gLS[] = { chLatin_L,  chLatin_S,  chNull };
> DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
> DOMLSSerializer*  myWriter = (impl)->createLSSerializer();
> DOMConfiguration* dc = myWriter->getDomConfig();
> dc->setParameter( XMLUni::fgDOMWRTDiscardDefaultContent,true);
> // serialize the DOMNode to a UTF-16 string
> XMLCh* theXMLString_Unicode = myWriter->writeToString(toWrite.GetDOMNodePtr());
>
> 4) Convert theXMLString_Unicode  to char* and print using cout.
>  
>  I got the attribute printed this way.
> newattr="&#xA; Hello &#x9;&#x9; testing"
>  
>  
> Is there any way to get the attribute printed as newattr="
>  Hello  testing"
>  
>  
> Thanks,
> Mini
>
>
>       
>   


Mime
View raw message