Undefined item element XML/RSS

2019-07-27 10:55发布

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条回答
叼着烟拽天下
2楼-- · 2019-07-27 11:24

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.

查看更多
登录 后发表回答