使用 jquery 从 ATOM 文件中读取数据。

发布于 2024-08-20 05:56:37 字数 911 浏览 2 评论 0原文

我正在尝试读取 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);
        }
    });

Atom 文件有一个这样的字段:

<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>"

谢谢!!对不起英语!

i'm trying to read a xml/atom file, the code is:

 $.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);
        }
    });

The atom file has a field like this:

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

The code to read the content tag is:

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

this -> the entry part.

The problem is, when jQuery execute this line returns "Docentes y alumnos desa...". There is is a way that jQuery returns---->

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

Thanks!! and sorry for the english!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

才能让你更想念 2024-08-27 05:56:37
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

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

as from

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

:]

Edit: sorry, should read the api better.

Here they solve something similar: http://refactormycode.com/codes/341-jquery-all-descendent-text-nodes-within-a-node

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文