/** * @author Matt Shaw * @url http://sf.net/projects/xmlrpcflash * http://www.osflash.org/doku.php?id=xmlrpcflash */ import com.mattism.http.xmlrpc.Parser; import com.mattism.http.xmlrpc.util.XMLRPCUtils; import com.mattism.http.xmlrpc.util.XMLRPCDataTypes; class com.mattism.http.xmlrpc.ParserImpl implements Parser { // Metadata private var _VERSION:String = "1.0.0"; private var _PRODUCT:String = "ParserImpl"; // Constants private var ELEMENT_NODE:Number = 1; private var TEXT_NODE:Number = 3; private var METHOD_RESPONSE_NODE:String = "methodResponse"; private var PARAMS_NODE:String = "params"; private var PARAM_NODE:String = "param"; private var VALUE_NODE:String = "value"; private var FAULT_NODE:String = "fault"; private var ARRAY_NODE:String = "array"; private var DATA_NODE:String = "data"; private var STRUCT_NODE:String = "struct"; private var MEMBER_NODE:String = "member"; public function parse( xml:XML ):Object { trace(xml.toString()); if ( xml.toString().toLowerCase().indexOf('= 0 ){ trace("WARNING: XML-RPC Response looks like an html page."); return xml.toString(); } xml.ignoreWhite = true; return this._parse( xml.firstChild ); } private function _parse( node:XMLNode ):Object { var data:Object; if (node.nodeType == TEXT_NODE) { return node.nodeValue; } else if (node.nodeType == ELEMENT_NODE) { if ( node.nodeName == METHOD_RESPONSE_NODE || node.nodeName == PARAMS_NODE || node.nodeName == VALUE_NODE || node.nodeName == PARAM_NODE || node.nodeName == FAULT_NODE || node.nodeName == ARRAY_NODE ) { this.debug("_parse(): >> " + node.nodeName); return this._parse( node.firstChild ); } else if (node.nodeName == DATA_NODE) { this.debug("_parse(): >> Begin Array"); data = new Array(); for (var i:Number=0; i> Begin Struct"); data = new Object(); for (var i:Number=0; i " + a); } }