XML和JSON数据的解析
HtmlAll
window.onload = function()
{
var jsonObj =
{
"sno" : "110",
"sname" : "Jack",
"sex服务器托管网" : "男",
};
student = function(sno,sname,sex)
{
this.sno = sno;
this.sname = sname;
this.sex服务器托管网 = sex;
}
//访问json对象属性
// Json也被称为无类型对象,轻量级,轻巧,体积小,易解析
// alert(jsonObj.sno + jsonObj.sname + jsonObj.sex);
var stu = new student(jsonObj.sno,jsonObj.sname,jsonObj.sex);
// alert(stu.sno + stu.sname + stu.sex);
var students =
[
{
"sno" : "110",
"sname" : "Jack",
"sex" : "男",
},
{
"sno" : "120",
"sname" : "Rose",
"sex" : "女",
},
{
"sno" : "130",
"sname" : "Tim",
"sex" : "男",
}
];
for (var i = 0; i < students.length; i++)
{
var student = students[i];
// alert(student.sno + student.sname + student.sex);
}
var user =
{
"usercode" : 110,
"username" : "Rose",
"sex" : true,
"address" : {
"city" : "北京",
"street" : "大兴区",
"zipcode" : "12221231"
},
"aihao" : ["smoke","drink","tt"]
};
// 访问人名以及居住的城市
// alert(user.username + user.address.city);
//描述整个班级
var iop =
{
"total" : 3,
"studentInfo" : [
{
"usercode" : 110,
"username" : "Rose",
"sex" : true,
"address" : {
"city" : "北京",
"street" : "大兴区",
"zipcode" : "12221231"
},
"aihao" : ["smoke","drink","tt"]
},
{
"usercode" : 110,
"username" : "Jack",
"sex" : true,
"address" : {
"city" : "北京",
"street" : "大兴区",
"zipcode" : "12221231"
},
"aihao" : ["smoke","drink","tt"]
},
{
"usercode" : 110,
"username" : "Tim",
"sex" : true,
"address" : {
"city" : "北京",
"street" : "大兴区",
"zipcode" : "12221231"
},
"aihao" : ["smoke","drink","tt"]
}
]
}
//遍历学生表所有的学生名字
for (var i = 0; i < iop.studentInfo.length; i++) {
alert(iop.studentInfo[i].username);
}
}
xml
1
1
2
1
3
1
4
1
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
数据技术都能四世同堂,凭什么开发 30 岁就要被干掉? 前言 履约管理是一个面向物流商家的OMS工作台,自从初代目把架子搭起来之后,就没有继续投入了,后来一直是合作伙伴同学在负责日常维护和需求支撑。经过几年的野蛮生长,系统已经杂草丛生,乱象百出。再后来,甚至一…