I think you'd have to modify the serializer, and I'm not sure how you'd know 
when to serialize quotes as character entities.  From an XML standpoint, 
there's no need to use an entity in this context, so the Xerces serializer does 
the most efficient thing; the entity and the character are semantically 
equivalent.

-----Original Message-----
From: mini thomas [mailto:mini_mol_tho...@yahoo.com]
Sent: Tue 5/5/2009 8:29 AM
To: c-users@xerces.apache.org
Subject: DOMLSSerializer -- serialize with entity node intact
 
 Hi,

I am serializing the following xml to a character string.
 
<NPCONF>
    <UICFG>
        <CFGEXUI name="UserDefineDlg" position="undocked">hide</CFGEXUI>
        &lt;myconf &quot; /&gt;  
        <CFGEXUI name="EdgeLine" nbColumn="200" />
    </UICFG>
</NPCONF>
 
part of code used.....
  static const XMLCh gLS[] = { chLatin_L,  chLatin_S,  chNull };
  DOMImplementation *impl =  
DOMImplementationRegistry::getDOMImplementation(gLS);
  DOMLSSerializer*  myWriter = (( 
DOMImplementationLS*)impl)->createLSSerializer();
  DOMConfiguration* dc = myWriter->getDomConfig();
  dc->setParameter( XMLUni::fgDOMWRTDiscardDefaultContent,true);
  dc->setParameter( XMLUni::fgDOMWRTEntities,true);
  XMLCh* theXMLString_Unicode = myWriter->writeToString(dom_root_node);
  //convert theXMLString_Unicode  to character string ...
 
 
Irrespective of the fgDOMWRTEntities attribute I get the following output

<NPCONF>
    <UICFG>
        <CFGEXUI name="UserDefineDlg" position="undocked">hide</CFGEXUI>
        &lt;myconf " /&gt;
        <CFGEXUI name="EdgeLine" nbColumn="200"/>
    </UICFG>
</NPCONF>

I don't want &quot; to be replaced with " .
 
Is there any way to do this ? ( I have already done this by traversing through 
the DOM tree and printing the node and contents. But I want to use 
DOMLSSerializer as it can give a huge performance improvement)

Thanks in advance
Mini


      

Reply via email to