日期:2013-12-04 浏览次数:20561 次
四、处理XML对象的函数:
myXML.onLoad = function(success)
{
statements;
}
五、data.XML文件的内容:
<data1 name="imagebear">
<data2 name="mariger">
xiaoshandong
</data2>
<data3 name="mariger3">
xiaoshandong3
</data3>
</data1>
六、前往值实例
1、myXML.childNodes[0]将前往:
<data1 name="imagebear">
<data2 name="mariger">
xiaoshandong
</data2>
<data3 name="mariger3">
xiaoshandong3
</data3>
</data1>
8、var myName = myXML.firstChild.firstChild;trace(myName.nodeName);将输出data2myName = myName.nextSibling;trace(myName.nodeName);将输出data3
childNodes[0]等价于firstChild
七、附:测试用的代码,XML文件如楼上所示
var myXML = new XML();
myXML.load("data.xml");
myXML.ignoreWhite = true;
myXML.onLoad = function(success)
{
if(success)
{
//myArray = myXML.childNodes[0];
//trace(myArray.attributes.name);
//trace(myXML.childNodes[0].childNodes[1].firstChild.nodeValue);
//trace(myXML.firstChild);
//trace(myXML.childNodes[0].nodeName);
//trace(myXML.firstChild.attributes.name);
//trace(myXML.childNodes[0].childNodes[1].nodeName);
//trace(myXML.childNodes[0].childNodes[1].attributes.name);
//trace(myXML.firstChild.firstChild);
//trace(myXML.firstChild.firstChild.nodeName);
//trace(myXML.firstChild.firstChild.attributes.name);
//trace(myXML.childNodes[0].childNodes[0].childNodes[0].nodeValue);
var myName = myXML.firstChild.firstChild;
trace(myName.nodeName);
myName = myName.nextSibling;
trace(myName.nodeName);
}
}