Undefined item element XML/RSS

时光总嘲笑我的痴心妄想 提交于 2019-12-14 02:29:31

问题


I modified the Wordpress RSS feed, but I get RSS validation errors. How do I fix these? Where/how do I define these name spaces etc.?

Undefined item element: content:custom

http://tinyurl.com/npgmha3


回答1:


Based on discussion in the comments, your actual problem is this:

I want to add some custom tags to my RSS feed so that it is treated as a valid feed, but my own script can get some extra information out of it which other readers will completely ignore.

In your attempted solution, you have added these into an existing namespace, which the W3C's validation service has knowledge of, and is thus rejecting the elements.

The right way to define your own elements is in your own namespace - since you control the namespace, nobody but you can say that your elements are "wrong" in that namespace. This requires only three steps:

  1. Pick a URI that you control to be the namespace identifier, e.g. http://teleeon.com/custom-rss-extensions/. You don't actually have to put anything particular at this URL, although a page explaining why you've done it might be useful for anyone curious who comes across it in your feed.
  2. Assign an alias at the top of the feed to that namespace, along with all the existing ones, e.g. xmlns:teleeon="http://teleeon.com/custom-rss-extensions/"
  3. Prefix all your elements (and attributes) with that custom namespace alias, e.g. <teleeon:customContent teleeon:key='test_field'>fasdfsadfsadf åäö http://www.adasdasd.com</teleeon:customContent>

If you want to have your images and custom fields as separate namespaces, just repeat steps 1 to 3 for a second namespace.



来源:https://stackoverflow.com/questions/20302882/undefined-item-element-xml-rss

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!