觉的还是挺方便的,虽然还不完善,想用的就将着用吧.
/*
*
* @author:HellHeaven
* @version:1.0
* @email:hellheaven@gmail.com
*/
class myxml extends XML
{
private var myArray : Array;
public var fc : Array;
function myxml ()
{
ignoreWhite = true;
}
function xml2array (mydata)
{
myArray=new Array();
var mydata2 = mydata;
while (mydata2 != null)
{
myArray.push (getdata (mydata2));
mydata2 = mydata2.nextSibling;
}
return myArray;
}
function getdata (abc)
{
var a = new Object ();
for (var i in fc)
{
a [fc [i]] = abc.attributes [fc [i]];
}
return a;
}
}
//////////////////////////////////////
这样调用:
var tempXml = new myxml ();
tempXml.fc = ["housetype", "mode", "paymode", "minyear", "maxyear", "maxprice", "pircerate", "orthas", "rate"];
tempXml.onLoad = function (s)
{
if (s)
{
db_rate = tempXml.xml2array (tempXml.firstChild.firstChild);
trace (db_rate);
}
}
tempXml.load ("http://127.0.0.1/system/getrate.asp");
getrate.asp返回的是一个xml数据,有这些属性
["housetype", "mode", "paymode", "minyear", "maxyear", "maxprice", "pircerate", "orthas", "rate"]