Javascript 使用ChereIO解析xml的nodejs返回空CDATA

Javascript 使用ChereIO解析xml的nodejs返回空CDATA,javascript,xml,node.js,cdata,cheerio,Javascript,Xml,Node.js,Cdata,Cheerio,我正在nodejs中使用cheerio解析一些rss提要。我正在抓取所有物品,将它们放入一个数组中。我使用了3个测试提要,所有这些提要都有一个“description”子元素用于每个“item”元素。在其中一个提要中,整个“描述”被包装为CDATA,我无法获得它的值。下面是一段简短的代码片段 //Open the xml document with cheerio $ = cheerio.load(arrXmlDocs[i],{ ignoreWhitespace : true, xmlMode

我正在nodejs中使用cheerio解析一些rss提要。我正在抓取所有物品,将它们放入一个数组中。我使用了3个测试提要,所有这些提要都有一个“description”子元素用于每个“item”元素。在其中一个提要中,整个“描述”被包装为CDATA,我无法获得它的值。下面是一段简短的代码片段

//Open the xml document with cheerio
$ = cheerio.load(arrXmlDocs[i],{ ignoreWhitespace : true, xmlMode : true});

//Loop through every item
$('item').each(function(i, xmlItem){

    //array to hold each item being converted into an array
    var tempArray = [];

    //Loop through each child of <item>
    $(xmlItem).children().each(function(i, xmlItem){
        //Get the name 
        tempArray[$(this)[0].name] = $(this).text();
    }

}
带有CDATA描述的提要如下所示

[
    [
        name: 'name of episode',
        description:'description of episode',
        pubdate: 'published date'
    ],
    [
        name: 'name of episode',
        description:'description of episode',
        pubdate: 'published date'
    ]
]
    [
        name: 'name of episode',
        pubdate: 'published date'
    ],
所以我的问题是:为什么ChereIO不返回CDATA中包装的值/如何使其返回这些值。

这是ChereIO的()。在您的情况下,还无法使用
CDATA
从XML创建正确的树。我知道这是一个令人失望的答案,这是WIP

它正在处理中,同时,您可以使用正则表达式删除
CDATA

arrXmlDocs[i].replace(/<!\[CDATA\[([\s\S]*?)\]\]>(?=\s*<)/gi, "$1");

arrXmlDocs[i].replace(/(?=\s*你能更清楚地说明你在问什么吗?更新以更清楚地提问。