Xml::elementsNamed failed when xml contains xmlns="http://ns.adobe.com/xfl/2008/"

44 views
Skip to first unread message

superboy

unread,
Sep 24, 2013, 11:03:34 PM9/24/13
to haxe...@googlegroups.com
Xml::elementsNamed failed when xml contains xmlns="http://ns.adobe.com/xfl/2008/
    private function unknown(strXml:String):Void {
        var xmlDoc:Xml = Xml.parse(strXml);
        var domDoc:Xml = xmlDoc.firstElement();
        for (elt in domDoc.elements()) {

            if (elt.nodeName == "publishHistory")
                trace(elt);
        }
        trace("///////////////");
        var dl:Xml = domDoc.elementsNamed("publishHistory").next();// elementsNamed runs failed
        trace(dl); //null
    }
    private  function test() {
trace("XML Load From String");
        unknown("<DOMDocument xmlns=\"http://ns.adobe.com/xfl/2008/\">
<publishHistory>
  <PublishItem publishSize=\"165690\" publishTime=\"1380008796\" publishDebug=\"true\"/>
 </publishHistory>
</DOMDocument>"); // elementsNamed runs failed
    }

Nicolas Cannasse

unread,
Sep 25, 2013, 3:39:20 AM9/25/13
to haxe...@googlegroups.com
Le 25/09/2013 05:03, superboy a �crit :
> Xml::elementsNamed failed when xml contains
> xmlns="http://ns.adobe.com/xfl/2008/"

There's quite annoying things occurring when using Flash XML parser with
xmlns attributes. I remember trying to fix some of these but not sure I
could do it right. Maybe try .split("xmlns=").join("_xmlns=") before
parsing.

Or you can use (slower but fully crossplatform)
haxe.xml.Parser.parse(xmlString)

Best,
Nicolas
Reply all
Reply to author
Forward
0 new messages