core: Implement XML.toString for comments and processing instructions

This commit is contained in:
Nathan Adams 2023-08-12 13:05:56 +02:00
parent af1cb4ebd9
commit db7c6dec00
4 changed files with 14 additions and 2 deletions

View File

@ -649,7 +649,9 @@ impl<'gc> E4XNode<'gc> {
return Ok(to_xml_string(E4XOrXml::E4X(*self), activation));
}
other => Err(format!("XML.toString(): Not yet implemented for {other:?}").into()),
E4XNodeKind::Comment(_) | E4XNodeKind::ProcessingInstruction(_) => {
return Ok(to_xml_string(E4XOrXml::E4X(*self), activation));
}
}
}

View File

@ -1,10 +1,12 @@
package {
package {
import flash.display.Sprite;
public class Test extends Sprite { }
}
// FIXME: Implement indentation.
XML.prettyPrinting = false;
XML.ignoreComments = false;
XML.ignoreProcessingInstructions = false;
var xml = <animal id="1">Cow</animal>
trace("xml.toString(): " + xml.toString());
@ -20,3 +22,9 @@ trace("xml.toString(): " + xml.toString());
xml = <foo><bar x="a&quot;b">&gt;&amp;&lt;</bar></foo>;
trace("xml.toString(): " + xml.toString());
xml = <!-- some comment -->;
trace("xml.toString(): " + xml.toString());
xml = <? processing instruction! ?>;
trace("xml.toString(): " + xml.toString());

View File

@ -2,3 +2,5 @@ xml.toString(): Cow
xml.toString(): <animals><animal id="1">Cow</animal><animal id="2">Pig</animal></animals>
xml.toString(): <foo><bar a="x" b="y" c="z"/></foo>
xml.toString(): <foo><bar x="a&quot;b">&gt;&amp;&lt;</bar></foo>
xml.toString(): <!-- some comment -->
xml.toString(): <? processing instruction! ?>