3

i tried load XML document and save an exact copy. Problem is all line feed symbol (#10, hex 0A) are replaced with carriage return. (#13#10, hex 0D0A)

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Information -->
<AddInsList>
  <AddInItem ID="name1">
    <Title DefaultText="Some text">
      <tag1><![CDATA[Some text]]></tag1>
    </Title>
    <Description DefaultText="some informations">
      <tag1><![CDATA[**Some text with line feed symbols 0A**]]></tag1>
    </Description>
  </AddInItem>
</AddInsList>

my code:

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, XMLIntf, XMLDoc, ActiveX, xmldom, StdCtrls, ComCtrls;

var
  Doc : IXMLDocument;

Begin
  Doc:=NewXMLDocument;

  //Prevent to change white spaces to tabulators
  Doc.ParseOptions := Doc.ParseOptions+[poValidateOnParse]+[poPreserveWhiteSpace];

  Doc.LoadFromFile('C:\test.xml');
  Doc.SaveToFile('C:\exact.xml');
End;
4

1 回答 1

0

XML 解析规范换行;XML 序列化负责决定是否将它们转换回 CRLF 形式。见http://www.w3.org/TR/REC-xml/#sec-line-ends

于 2013-12-24T03:37:44.860 回答