Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML not working #204

Open
ezakto opened this issue Mar 8, 2018 · 0 comments · May be fixed by #209
Open

XML not working #204

ezakto opened this issue Mar 8, 2018 · 0 comments · May be fixed by #209

Comments

@ezakto
Copy link

ezakto commented Mar 8, 2018

I'm trying to parse a simple rss feed:

const osmosis = require('osmosis');

const xml = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title><![CDATA[Test]]></title>
    <link>http://www.example.com</link>
    <description><![CDATA[Lorem ipsum]]></description>
    <item>
      <title><![CDATA[Lorem ipsum]]></title>
      <link>http://www.example.com/</link>
      <description><![CDATA[Lorem ipsum dolor]]></description>
      <pubDate><![CDATA[Thu, 08 Mar 2018 00:09:56 -0300]]></pubDate>
    </item>
    <item>
      <title><![CDATA[Lorem ipsum]]></title>
      <link>http://www.example.com/</link>
      <description><![CDATA[Lorem ipsum dolor]]></description>
      <pubDate><![CDATA[Thu, 08 Mar 2018 00:09:56 -0300]]></pubDate>
    </item>
  </channel>
</rss>`;

osmosis
  .parse(xml)
  .find('item')
  .set({
    title: 'title',
    link: 'link',
  })
  .data(console.log);

But the output is always:

{ title: '', link: '' }
{ title: '', link: '' }

If I remove all the <![CDATA[ and ]]>, I get this output:

{ title: 'Lorem ipsum', link: '' }
{ title: 'Lorem ipsum', link: '' }

Which is still wrong :c
This happens in both .parse(xml) and .get(url)...
Looks like it happens to some (or all?) RSS feeds. Osmosis 1.1.6

Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant