首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery 读取xml有关问题

2012-05-16 
jquery 读取xml问题各位大虾,请教个问题,jquery 读取xml 比如我要获取 属性bind是userCode 的bop节点,怎么

jquery 读取xml问题
各位大虾,请教个问题,jquery 读取xml 比如我要获取 属性bind是userCode 的bop节点,怎么快速获取到,而不是用循环一个个节点比较获取

<bo xmlns="http://www.w3.org/1999/xhtml" operationstatus="init" userid="0" index="1">
<bop bind="id"><!--[CDATA[780]]--></bop>
<bop bind="userName"><!--[CDATA[管理员]]--></bop>
<bop bind="userNameEn"><!--[CDATA[system]]--></bop>
<bop bind="userCode"><!--[CDATA[system]]--></bop>
</bo>

[解决办法]

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script></head><body><script type="text/javascript">var xml = '<bo xmlns="http://www.w3.org/1999/xhtml" operationstatus="init" userid="0" index="1">\<bop bind="id"><!--[CDATA[780]]--></bop>\<bop bind="userName"><!--[CDATA[管理员]]--></bop>\<bop bind="userNameEn"><!--[CDATA[system]]--></bop>\<bop bind="userCode"><!--[CDATA[system]]--></bop>\</bo>';xml = $($.parseXML(xml));xml.find("bop[bind='userCode']").each( function() {    alert($(this).html());});</script></body></html>
[解决办法]
楼主通读下jquery的api,很多问题轻松就可以解决。
[解决办法]
探讨

$(this).text(); 为什么拿不到值呢,费解

热点排行