WEB开发网
开发学院手机开发Symbian 开发 Symbian WRT中使用JS自动将XML、JSON转换成为对象... 阅读

Symbian WRT中使用JS自动将XML、JSON转换成为对象

 2010-08-30 00:03:00 来源:WEB开发网   
核心提示:nodeName: 'guid',//节点名称memberName: 'isPermaLink',//数据放在对象中的成员变量名称nodeValueOrAttribute: 'attribute',//是取属性的值还是取元素的文本?attribute:取得属性值,node

nodeName: 'guid',//节点名称

memberName: 'isPermaLink',//数据放在对象中的成员变量名称

nodeValueOrAttribute: 'attribute',//是取属性的值还是取元素的文本?attribute:取得属性值,nodeValue:取得节点值

attributeName: 'isPermaLink'//取哪个属性?

}, {

nodeName: 'description',//节点名称

memberName: 'description',

nodeValueOrAttribute: 'nodeValue'

}, {

nodeName: 'guid',//节点名称

memberName: 'guidValue',

nodeValueOrAttribute: 'nodeValue'

}];

var options2 = [{

nodeName: 'title',//节点名称

memberName: 'title',//数据放在对象中的成员变量名称

nodeValueOrAttribute: 'nodeValue',//attribute:取得属性值,nodeValue:取得节点值

}, {

nodeName: 'description',//节点名称

memberName: 'description',

nodeValueOrAttribute: 'nodeValue'

}, {

nodeName: 'link',//节点名称

memberName: 'link',

nodeValueOrAttribute: 'nodeValue'

}, {

nodeName: 'author',//节点名称

memberName: 'author',

nodeValueOrAttribute: 'nodeValue'

}, {

nodeName: 'category',//节点名称

memberName: 'category',

nodeValueOrAttribute: 'nodeValue'

}];

/*

processData = new ProcessData(e, "item",options2 , function(data){

// alert(data.length);

alert(data[0].title +" "+data[0].category +" "+data[0].description);

});

processData.buildxml(); //这里要传递一个异常处理函数,当网络有问题的时候会自动调用

*/

/////JSON

var sss = "http://json.com/brands.txt";

processData = new ProcessData(sss, "item", options2, function(json){

alert(json.brands[1].brand);

});

processData.buildJSON();//这里要传递一个异常处理函数,当网络有问题的时候会自动调用

上一页  5 6 7 8 9 10 11  下一页

Tags:Symbian WRT 使用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接