• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

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(memoutput) as IStream;
      sax.parse(AXML);
      memoutput.Position := 0;
      memoutput.SaveToFile(APath);
    finally
      memoutput.Free;
    end;
  finally
    wrt := nil;
    sax := nil;
  end;
end;
0
Eddie Shipman
Asked:
Eddie Shipman
  • 2
1 Solution
 
Eddie ShipmanAll-around developerAuthor Commented:
BTW, using the IXMLDOMDocument save method DOES NOT place the PI in the document but it is not
indented.
Yes, I have tried the preserveWhiteSpace property, with no effect.
0
 
Geert BormansCommented:
have you tried
   wrt.omitXMLDeclaration := True;
0
 
Eddie ShipmanAll-around developerAuthor Commented:
I thought Itried that, too, we'll see..
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now