Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread XMLSerializer
Wed, May 29 2013 12:55 PMPermanent Link

matthewk

Without XMLSerializer, how can I get the XML that has been built with a TDocument?
Thu, May 30 2013 4:45 AMPermanent Link

Matthew Jones

Search back for getDOMfromXMLstring and it may give you what you need. If not, more
detail please?

/Matthew Jones/ (Just an EWB user)
Thu, May 30 2013 5:22 AMPermanent Link

matthewk

OK, that's not quite what I needed, but shows how to do it, so thanks. For the record:

function getXMLStringFromDocument(doc) {
   return new XMLSerializer().serializeToString(doc);
}

and:

external function getXMLStringFromDocument(doc : TDocument): String;
Thu, May 30 2013 1:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< OK, that's not quite what I needed, but shows how to do it, so thanks.
For the record: >>

IE9 and lower is going to have an issue with that.  For those browsers, you
can just examine the xml property of the node (or document).  This is
already defined in the WebDOM unit, and I'll add the XMLSerializer interface
for 1.02, and this is what it will look like:

WebDOM:

  external TXMLSerializer = class
     public
        { Methods }
        function serializeToString(node: TNode): String;
     end;

WebCore:

function SerializeXML(Document: TDocument): String;
var
  TempSerializer: TXMLSerializer;
begin
  if (IsIE and (not IsIEHTML5)) then
     Result:=Document.xml
  else
     begin
     TempSerializer:=TXMLSerializer.Create;
     try
        Result:=TempSerializer.serializeToString(Document);
     finally
        TempSerializer.Free;
     end;
     end;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Fri, May 31 2013 5:37 AMPermanent Link

matthewk

Thank you. By the way https://developer.mozilla.org/en/docs/XMLSerializer says that it is supported in IE9.
Fri, May 31 2013 3:58 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Thank you. By the way https://developer.mozilla.org/en/docs/XMLSerializer
says that it is supported in IE9. >>

Sorry about that.  Yes, I was incorrect and forgot to correct my statement
(the code was correct, though Smile).

There was some mention online that IE9 implements the object but not the
serializeToString method, but that was apparently wrong.

Tim Young
Elevate Software
www.elevatesoft.com
Image