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;
LVL 26
Eddie ShipmanAll-around developerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 BormansInformation ArchitectCommented:
have you tried
   wrt.omitXMLDeclaration := True;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eddie ShipmanAll-around developerAuthor Commented:
I thought Itried that, too, we'll see..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.