node-rss
node-rss copied to clipboard
No CDATA
Is it possible to create XML without a CDATA?
It should be, what does your code look like?
console.log(new RSS({
title: "hello"
}).xml("\t"));
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title><![CDATA[hello]]></title>
<description><![CDATA[hello]]></description>
<link>http://github.com/dylan/node-rss</link>
<generator>RSS for Node</generator>
<lastBuildDate>Sun, 09 Feb 2014 15:57:10 GMT</lastBuildDate>
</channel>
</rss>
Pull request: https://github.com/dylang/node-rss/pull/28
Thank you for the pull request!
I replied quickly on my phone without looking carefully and thought you were asking about node-xml, not this one.
I put those in ![CDATA
because I wasn't sure if the text would be valid for XML. Do you think there's a way to check the string and automatically wrap with ![CDATA
only when needed?
According to http://www.w3.org/TR/REC-xml/#syntax it looks like CDATA
is only needed when the string has <
, >
, or &
. What do you think checking for those strings and only using CDATA
when one of them is found?
Actually xml module making this work
var xml = require("xml");
console.log(xml({hello:"lol"})); //<hello>lol</hello>
console.log(xml({hello:"<lol>"})); //<hello><lol></hello>
Is this and #28 still needed?
Right now I'm not working on a project which used it, but why not?
If nobody is having problems with the current code I'd rather not change the code which could potentially introduce new problems.
Sounds like a death sentence.
I would be in favour of making this change, it seems unnecessary to have CDATA everywhere when it is only required if the string contains one of three characters, which is a rarity. It's definitely aesthetics rather than having a true technical grounding, but when you compare an RSS feed from Ghost to one from another platform ours look really messy and we are really keen to do much better in this area.
bump/update/eta?