Name

XML.toString( ) Method — the source code of the XML node, as a string

Availability

Flash 5

Synopsis

theNode.toString( )

Returns

A string representing the source code of the XML object hierarchy starting at theNode.

Description

The toString( ) method converts an XML node object or an XML document object to its analogous XML source code. If theNode is a top-level XML document object, any DOCTYPE and XML declaration tags are included in the string. If the document’s ignoreWhite property is false, whitespace is preserved and the document source code appears as it did when it was parsed.

It’s not normally necessary to invoke toString( ) explicitly; toString( ) is automatically invoked any time theNode is used in a string context.

Example

var myDoc = new XML('<?xml version="1.0"?><!DOCTYPE foo SYSTEM "bar.dtd"><BOOK>       
<TITLE>ActionScript: The Definitive Guide</TITLE>'
  + '<AUTHOR SALUTATION="Mr">Colin Moock  </AUTHOR>    '
  + '<PUBLISHER>O\'reilly & Associates, Inc</PUBLISHER>    </BOOK>');

trace(myDoc.toString( ));
// Displays:
<?xml version="1.0"?><!DOCTYPE foo SYSTEM "bar.dtd">
<BOOK>       <TITLE>ActionScript:
 The Definitive Guide</TITLE><AUTHOR SALUTATION="Mr">Colin 
Moock  </AUTHOR>    <PUBLISHER>O'reilly & Associates, Inc
</PUBLISHER>    </BOOK>

See Also

Object.toString( ), XML .nodeValue

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.