Is there a way to make SignedXml class generate resulting XML with linebreaks between elements?
Because now, doing this:
{
SignedXml^ signedXml = gcnew SignedXml();
.....
signedXml->ComputeSignature();//Write to file
XmlDocument^ xmlDoc = gcnew XmlDocument();
xmlDoc->PreserveWhitespace = true;
XmlNode^ signedNode = xmlDoc->ImportNode(signedXml->GetXml(), true);
xmlDoc->AppendChild(signedNode);
XmlTextWriter^ xmltw = gcnew XmlTextWriter("d:\\output xml.xml", gcnew Text::UTF8Encoding(false));
xmlDoc->WriteTo(xmltw);
xmltw->Close();//Write to file. 2nd method
WriteXMLFile(signedXml->GetXml(), "d:\singed xml.xml");
}
void WriteXMLFile(XmlNode^ XML, String^ FilePath)
{
XmlWriterSettings^ settings = gcnew XmlWriterSettings();
settings->Encoding = System::Text::Encoding::UTF8;
settings->OmitXmlDeclaration = true;
settings->NewLineChars = "\n";
settings->Indent;
XmlWriter^ xwriter = XmlWriter::Create(FilePath, settings);
XML->WriteTo(xwriter);
xwriter->Close();
}
I get XML in a single line, like this:
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
What I want, is to get an easily readable XML like this:
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />