You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Load sample XML file with <?xml ... ?> header (see below)
2. Save file back to disk
What is the expected output? What do you see instead?
I expected to see a single header line, but after loading the document from
disk an additional header line is added (and subsequently written back to disk).
What version of the product are you using? On what operating system?
v1.16 (2013-07-01) on Delphi XE2 / Win 7 x64
Please provide any additional information below.
Sample file:
data.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<system>
<items>
<item/>
</items>
</system>
var
gDoc : IXMLDocument;
begin
gDoc := CreateXMLDoc;
gDoc.Load('data.xml');
gDoc.XML now contains:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<system>
<items>
<item/>
</items>
</system>
Original issue reported on code.google.com by [email protected] on 1 Oct 2013 at 10:08
The text was updated successfully, but these errors were encountered:
It looks like what was happening is that after parsing the first line of the
file (OmniXml.pas line 3411) the code tries to detect the encoding of the file,
and if found, rewinds the input stream reader so that it can read the contents
a second time.
I'm guessing that the output pointer isn't reset, and so on the second pass
(now with the correct encoding) it re-reads the first line into the output file
(or appends that same element to the XML structure).
I worked around this by using the following code to load my XML file:
Doc := CreateXMLDoc;
FS := TFileStream.Create('data.xml', fmOpenRead or fmShareDenyNone);
try
Doc.LoadFromStream(FS, CP_UTF8);
finally
FS.Free;
end;
Original issue reported on code.google.com by
[email protected]
on 1 Oct 2013 at 10:08The text was updated successfully, but these errors were encountered: