gpt4 book ai didi

javascript - 使用 Jquery 解析 xml 并出现错误

转载 作者:行者123 更新时间:2023-12-01 05:23:08 24 4
gpt4 key购买 nike

我正在尝试使用以下代码片段解析 xml feed 源:

<script>      
$.get('http://...', function (data) {
$(data).find("entry").each(function () { // or "item" or whatever suits your feed
var el = $(this);

console.log("------------------------");
console.log("title : " + el.find("title").text());
console.log("author : " + el.find("author").text());
console.log("description: " + el.find("description").text());
});
});
</script>

注意:当我用任何 xml rss 源替换 "http://..." 时,我收到一条错误消息:

Failed to load resource: net::ERR_INSECURE_RESPONSE

当我将 http 更改为 https 时,控制台中仍然出现以下错误:

GET https:... net::ERR_INSECURE_RESPONSE

  1. 如何建立安全连接......
  2. 是否有更好的方法使用 javascript 或 Jquery 解析 xml feed(我不想使用 PHP 或任何其他...)。最初我使用 google Api 来解析提要,但该 API 不再受支持“https://developers.google.com/feed/ ”,您知道还有其他用于解析提要的 API/库吗?

最佳答案

使用 $.parseXML(data) 而不是 $(data),例如:

$.get('http://...', function (data) {
$.parseXML(data).find("entry").each(function () {
//...
});
});

关于javascript - 使用 Jquery 解析 xml 并出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41772970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com