8,906
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="utf-8"?>
<messages>
<box userid="123123123123123">
<content>阿什顿</content>
<author>飞快地疾驰</author>
<picurl>./img/head_pic/7.jpg</picurl>
<time>2016-7-25 11:26:30</time>
</box>
<box userid="43859749879832492">
<content>山东</content>
<author>强扭的瓜不甜</author>
<picurl>./img/head_pic/3.jpg</picurl>
<time>2016-7-25 11:26:44</time>
</box>
<box userid="1090238432848">
<content>按时</content>
<author>深深地伤害</author>
<picurl>./img/head_pic/9.jpg</picurl>
<time>2016-7-25 13:4:15</time>
</box>
</messages>
function init(){
$.ajax({
url: 'comment.xml',
type: 'GET',
dataType: 'xml',
success:function(data){
$(data).find('box').each(function() {
var back_content = $(this).find('content').text();
var back_username = $(this).find('author').text();
var back_pic_url = $(this).find('picurl').text();
var back_time = $(this).find('time').text();
var disparity = GetDateDiff(back_time,get_postTime());
//console.info(back_content+back_username+back_pic_url+back_time);
$("#chatbox").append('<li class="chat_detail"><div class="user_pic"><img src="'+back_pic_url+'"
outermost_XML_Name = data.firstChild.nodeName;//获取到的最外层的节点的名称
index.js:60 Uncaught TypeError: Cannot read property 'nodeName' of undefined
试了好几种方法也没有获取到数据,就直接写了XML的标签名进去了,这样倒是OK,可是不是我想要...放弃了这个方法,用JQ的 each来遍历这个XML成数组 在网上找了找相应的功能代码,并没有详细记载的.大部分还是以手动添加的标签名为主