Eddie Shipman
asked on
Not include ProcessingInstruction, please
I am using the Delphi code below to save my IXMLDOMDocument2 to a file, I am using this because it makes it human readable.
However, I do not require the ProcessingInstruction. I am not creating one in the document so I'm thinking this code is somehow putting it in there. Any thoughts??
procedure SaveXML(AXML: IXMLDOMDocument2; APath: String);
var
wrt: MXXMLWriter40;
sax: SAXXMLReader40;
memoutput: TMemoryStream;
begin
wrt := CoMXXMLWriter40.Create;
sax := CoSAXXMLReader40.Create;
sax.contentHandler := (wrt as IVBSAXContentHandler) ;
sax.dtdHandler := (wrt as IVBSAXDTDHandler);
sax.errorHandler := (wrt as IVBSAXErrorHandler);
sax.putProperty('http://xml.org/sax/properties/declaration-handler', wrt);
sax.putProperty('http://xml.org/sax/properties/lexical-handler', wrt);
try
wrt.indent := True;
wrt.disableOutputEscaping := True;
wrt.omitXMLDeclaration := False;
memoutput := TMemoryStream.Create;
try
wrt.output := TStreamAdapter.Create(memo utput) as IStream;
sax.parse(AXML);
memoutput.Position := 0;
memoutput.SaveToFile(APath );
finally
memoutput.Free;
end;
finally
wrt := nil;
sax := nil;
end;
end;
However, I do not require the ProcessingInstruction. I am not creating one in the document so I'm thinking this code is somehow putting it in there. Any thoughts??
procedure SaveXML(AXML: IXMLDOMDocument2; APath: String);
var
wrt: MXXMLWriter40;
sax: SAXXMLReader40;
memoutput: TMemoryStream;
begin
wrt := CoMXXMLWriter40.Create;
sax := CoSAXXMLReader40.Create;
sax.contentHandler := (wrt as IVBSAXContentHandler) ;
sax.dtdHandler := (wrt as IVBSAXDTDHandler);
sax.errorHandler := (wrt as IVBSAXErrorHandler);
sax.putProperty('http://xml.org/sax/properties/declaration-handler', wrt);
sax.putProperty('http://xml.org/sax/properties/lexical-handler', wrt);
try
wrt.indent := True;
wrt.disableOutputEscaping := True;
wrt.omitXMLDeclaration := False;
memoutput := TMemoryStream.Create;
try
wrt.output := TStreamAdapter.Create(memo
sax.parse(AXML);
memoutput.Position := 0;
memoutput.SaveToFile(APath
finally
memoutput.Free;
end;
finally
wrt := nil;
sax := nil;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I thought Itried that, too, we'll see..
ASKER
indented.
Yes, I have tried the preserveWhiteSpace property, with no effect.