Hi,

I serialized some of my program's data to XML using the DOM Load-and-Save
Serializer.
Because I want it more human readable, I set the "pretty print"
configuration option of the serializer to enabled.


domOutput_->setSystemId(destination.c_str());

if
(domSerializer_->getDomConfig()->canSetParameter(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint,
true)) {

domSerializer_->getDomConfig()->setParameter(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint,
true);
}

const auto ns = L"http://www.example.com/";;
auto document = domImplementation_->createDocument();

auto root = document->createElementNS(ns, L"customer");
root->setAttributeNS(L"http://www.w3.org/2000/xmlns/";, L"xmlns:xsi", L"
http://www.w3.org/2001/XMLSchema-instance";);
root->setAttributeNS(L"http://www.w3.org/2000/xmlns/";,
L"xsi:schemaLocation", L"http://www.example.com/ customer.xsd");
document->appendChild(root);

auto element = document->createElementNS(ns, L"id");
element->setTextContent(std::to_wstring(customer_->getID()).c_str());
root->appendChild(element);

element = document->createElementNS(ns, L"firstName");
xstring = transcodeNString(customer_->getFirstName().c_str());
element->setTextContent(xstring);
releaseWString(xstring);
root->appendChild(element);

element = document->createElementNS(ns, L"lastName");
xstring = transcodeNString(customer_->getLastName().c_str());
element->setTextContent(xstring);
releaseWString(xstring);
root->appendChild(element);

domSerializer_->write(document, domOutput_);


When I take a look at the generated XML file, I see that the node
indentation works just fine, but between each element, an empty line got
added:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<customer xmlns="http://www.example.com/"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://www.example.com/ customer.xsd">

  <id>1</id>

  <firstName>Max</firstName>

  <lastName>Mustermann</lastName>

</customer>


I paste the binary for this file as an image here, so you can inspect it.
http://fs5.directupload.net/images/161119/mu2hi9qs.png

How can I fix the output to not show those blanks?

Thank you.

Reply via email to