XML toString method not working as expected.
Why is the XML.toString method inconsistant?
var xml:XML = new XML( "<root/>" );
var xml_withtext:XML = new XML( "<root>a</root>" );
var xml_withchild:XML = new XML( "<root><child/></root>" );
trace(xml.toString()); //traces "" (blank)
trace(xml_withtext.toString()); //traces "a"
trace(xml_withchild.toString()); //traces "<root><child/></root>"
If the XML contains only a root node, toString prints nothing. When it contains text, it prints the text. That would make sense if toString was printing only the contents of the root node, but if the root node contains a child, it doesn't print "<child/>" as one would expect. Instead, it suddenly includes the root node as well in the string. That is inconsistant/unexpected. For some reason, there is also a separate toXMLString method that consistantly prints the entire XML structure. Was that some kind of patch since toString doesn't work in a consistant manner, instead opting to sometimes include the root node depending on whether it contains simple or complex content?
