I am using TXMLDocument to process a PAD file at http://repository.appvisor.com/info/app-9f00e7003a57/DataNumen_Access_Repair_pad.xml
Below is my code(XML Vendor is MSXML):
procedure ProcessFile1(const SrcFileName: string);
var
XmlFile: IXMLDocument;
begin
XmlFile := TXMLDocument.Create(nil);
try
XmlFile.LoadFromFile(SrcFileName);
XmlFile.SaveToFile(SrcFileName)
finally
end;
end;
My codes just load the file and then save it. The saved version is at https://www.datanumen.com/temp/pad/DataNumen_Access_Repair_pad1.xml
I use WinMerge to compare the two versions, and find the entities are all deleted in the saved version.
How to prevent this?
is the same as having#13
directly - the XML engine parses your entire markup into a DOM, and when you want to save it to XML again it is re-translated from DOM to text. At that point nobody would care if the source had an entity or the appropriate byte(s). By usingTXMLDocument
you operate on the DOM, not on text. If you want it 1:1 then copy the text, not its interpretation. Changing.DOMVendor
most likely won't help either.CRLF
line breaks in it, but whatever generator created the PAD file probably only supportsLF
and so escaped theCR
. ThenTXMLDocument
unescaped theCR
and saved it as a binary byte0x13
(since it doesn't require escaping per the XML spec) alongside the originalLF
, thus producing a validCRLF
, which WinMerge displays normally.