Once you set the XMLUni::fgDOMWRTFormatPrettyPrint property, the file will be formatted like this:

<personnel>

   <person>TEST</person>

   <email>TEST</email>

   <email2222222>
       <hello>TEST</hello>
   </email2222222>

</personnel>

If you don't like the extra newline between each node placed under the root element, and you would rather have

<personnel>
   <person>TEST</person>
   <email>TEST</email>
   <email2222222>
       <hello>TEST</hello>
   </email2222222>
</personnel>

then you have to set the XMLUni::fgDOMWRTXercesPrettyPrint property to "false"

Alberto



ss ak wrote:
can u explain a little more than this...

simply control the extra new line inserted ...how do i control them???

On Fri, Jul 31, 2009 at 11:03 AM, Alberto Massari
<[email protected]>wrote:

Correction: you want to set XMLUni::fgDOMWRTFormatPrettyPrint; the
XMLUni::fgDOMWRTXercesPrettyPrint simply control the extra new line inserted
between top level elements.

Alberto


Alberto Massari wrote:

It's not
pSerializer->setNewLine(XMLUni::fgDOMWRTXercesPrettyPrint);
it's
pSerializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTXercesPrettyPrint,
true);

Alberto

ss ak wrote:

 I get the xml into the file as a SINGLE LINE...
eg:

<?xml version="1.0" encoding="UTF-8" standalone="no" ><personnel><person>
TEST</person><email>TEST</email><email2222222><hello>TEST</hello></
email2222222></personnel>
what option/setting should i do to look in the form of XML

<person>test</person>
<email>test</email>


DOMLSSerializer *pSerializer =
((DOMImplementationLS*)impl)->createLSSerializer();DOMLSOutput
*theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();

pSerializer->setNewLine(XMLString::transcode("\n\r") );

pSerializer->setNewLine(XMLUni::fgDOMWRTXercesPrettyPrint);

XMLFormatTarget *myFormTarget = new
LocalFileFormatTarget(X("outfile.xml"));


 theOutputDesc->setByteStream(myFormTarget);

theOutputDesc->setEncoding(L"UTF-8");

 thanks,
pSerializer->write(xmldoc, theOutputDesc);






Reply via email to