将解析后的 XML 放入 JavaScript 数组中?

发布于 2024-10-10 06:16:10 字数 253 浏览 0 评论 0原文

我的挑战是获取 XML 提要,解析它,然后将解析后的数据放入 JavaScript 数组中,然后由 jquery 读取该数组并输出到页面上。 jquery 端已编写并使用静态数组。我还可以解析 XML。但是解析后的 XML 提要可以填充数组吗:

var text = new Array();  
text [1] = "first item parsed"  
text [2] = "second item parsed"  
etc.

My challenge is to take an XML feed, parse it, then put parsed data into a javascript array which is then read by jquery to output on a page. The jquery side is written and works with a static array. I also can parse the XML. But can a parsed XML feed populate an array such that:

var text = new Array();  
text [1] = "first item parsed"  
text [2] = "second item parsed"  
etc.

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

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

发布评论

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

评论(1

绅刃 2024-10-17 06:16:10

如果您可以简单地循环“items”,

请使用它按顺序将“items”添加到空白数组

var text = new Array();
$.each(xml_items, function(i,item) {
    text.push(item);
}

If you can simply loop through the "items"

use this to sequentially add "items" to a blank array

var text = new Array();
$.each(xml_items, function(i,item) {
    text.push(item);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文