Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery解析对象的xml get子级_Jquery_Xml_Rss - Fatal编程技术网

使用jquery解析对象的xml get子级

使用jquery解析对象的xml get子级,jquery,xml,rss,Jquery,Xml,Rss,使用jQ,我呈现了一个RSS提要,它可以工作: <script type="text/javascript"> jQuery(function($jQ) { $jQ.get('URL', function(data) { var $jQxml = $jQ(data); $jQxml.find("item").each(function() { var $jQthis = $jQ(this), item = { title:

使用jQ,我呈现了一个RSS提要,它可以工作:

<script type="text/javascript">
jQuery(function($jQ) {
$jQ.get('URL', function(data) {
   var $jQxml = $jQ(data);
   $jQxml.find("item").each(function() {
    var $jQthis = $jQ(this),
        item = {
            title: $jQthis.find("title").text(),
            link: $jQthis.find("link").text(),
            image: $jQthis.find("description").text()
    }
    console.log(item)
    });
   });
 });
不走运。关于如何获取此输出的img src有什么想法吗


提前谢谢

CDATA中包含HTML,因此必须首先对XML字符串使用jQuery的
parseXML()
,然后捕获
description
中的文本,即HTML字符串,然后必须将该HTML视为新的jQuery对象

尝试:


您尝试的示例需要前面的
$
src
周围的引号;这可能是个问题吗?谢谢,但这并没有解决。我也尝试过做jQthis.find(“description”).children(“p”).text();也不会输出任何值
<description><![CDATA[<p><img src="image.jpg"/></p>
<p>The post </p>
]]></description>
jQthis.find("description").children("img").attr("src");
var $jQxml = $jQ($jQ.parseXML(data));
var $description = $jQ($jQxml.find('description').text()); 
// then:
$description.find('img').attr('src');