【问题标题】:Read data from ATOM file with jquery.使用 jquery 从 ATOM 文件中读取数据。
【发布时间】:2010-01-29 09:12:06
【问题描述】:

我正在尝试读取一个 xml/atom 文件,代码是:

 $.ajax({
        type: 'GET',
        url: options.url,
        data: options.data,
        dataType: 'xml',
        async:options.async,
        success: function(xml) {
            var feed = new JFeed(xml);
            if(jQuery.isFunction(options.success)) options.success(feed);
        }
    });

原子文件有这样一个字段:

<entry>
  <content type="xhtml">
    <div xmlns="http://www.w3.org/1999/xhtml">Docentes y alumnos desa...</div>
  </content>
</entry>

读取内容标签的代码是:

jQuery(this).find('content').eq(0).text();

this -> 入口部分。

问题是,当 jQuery 执行时,这行返回“Docentes y alumnos desa...”。 jQuery有一种返回方式---->

"<div xmlns="http://www.w3.org/1999/xhtml">Docentes y alumnos desa...</div>"

谢谢!!对不起英语!

【问题讨论】:

    标签: jquery xml atom-feed


    【解决方案1】:
    jQuery(this).find('content').eq(0).html();
    

    http://api.jquery.com/html/

    :]

    编辑:抱歉,应该更好地阅读 api。

    他们在这里解决了类似的问题:http://refactormycode.com/codes/341-jquery-all-descendent-text-nodes-within-a-node

    【讨论】:

    • 没有男人! api 说:““此方法不适用于 XML 文档。”=/还有其他方法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多