Answer the question
In order to leave comments, you need to log in
Correct layout of RSS?
Good day. On the topic of the subject: I'm interested in how your RSS is typeset, and specifically what to do with tags? Delete or put in <![CDATA[]]>? I found a guide to creating RSS for news.yandex.ru, but nothing was said about tags there.
Answer the question
In order to leave comments, you need to log in
Generally rss must be valid xml.
The XML tells us that whatever data is inside <![CDATA[]]> will be output to the result tree as is. Those. if there is a < character in the node value, then it is better to use <![CDATA[]]>. Also note that xml does not understand mnemonics. Instead, you need to write or use <![CDATA[]]>.
For example, in the c_xml class ( www.phpclasses.org/package/7232-PHP-Convert-between-XML-files-and-arrays-or-strings.html ) I do this
static function valueToXML($value){
if (mb_strpos($value,'<')!==false || mb_strpos($value,'&')!==false) {
$value="<![CDATA[$value]]>";
}
return $value;
}
I don't think adding or removing <![CDATA[]]> will take long, check with the validator
Everything is simple with Yandex, if you have tags in rss, then you must use <![CDATA[]]>, if not, don’t use it, well, you need to replace special characters, that is, Yandex does not impose any restrictions. Therefore, it's easier to use <![CDATA[]]>.
I use the php class from habrovchanin zelenin. The class itself is here github.com/zelenin/rssgen Validation of RSS passes, without any CDATA.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question