26 September 2006
This post may be outdated due to it was written on 2006. The links may be broken. The code may be not working anymore. Leave comments if needed.
在以前的 blog 里提过 JSAN 的 XML.ObjTree. See javascript XML parser
最主要是 force_array 这个以前被我忽略了但非常有用的参数。

以前写起来比较麻烦,要用 if (tree.xml.message) { 来判断是不是一个。
现在发现有了 force_array, 就非常简单了。:)

var xotree = new XML.ObjTree();
xotree.force_array = [ "message" ];
var tree = xotree.parseXML( response );
for (i = 0; i <>不管有多少个 messages, 一律强制使用 array

any way, JSAN 和 XML.ObjTree 都非常好用。:)

blog comments powered by Disqus