使用copy()可以得到一份现有XML的值拷贝。
var kingdaCopy:XML = kingdaXML.copy();
对kingdaCopy操作就不会影响kingdaXML对象了。
4.极有用的descendants函数返回一个XMLList对象,包括所有的子节点。
设ignoreComments = false;和ignoreProcessingInstructions = false后,连comments和process instructions也会包含在这个XMLList对象中。
运用示例如下:
XML.ignoreComments = false;
var xml:XML =
<body>
<!-- comment -->
text1
<a>
<b>text2</b>
</a>
</body>;
trace(xml.descendants("*").length()); // 5
trace(xml.descendants("*")[0]); // // <!-- comment -->
trace(xml.descendants("*")[1].toXMLString()); // text1
trace(xml.descendants("a").toXMLString()); // <a><b>text2</b></a>
trace(xml.descendants("b").toXMLString()); // <b>text2</b>
还有太多的XML有用操作功能了(如对namespace的操作)。用到时再去翻参考书吧。
以上的介绍可以满足绝大部分运用了。
对了AS2.0已有的XML类,在3.0中变成了XMLDocument类,使用方法不变。便于AS2.0程序移植。其余不推荐。
下一次讲3.0的Web交互模型和运用吧。















