format_rss_channel() and format_rss_item() both have an $args argument for extra xml tags, but only format_rss_item() has a syntax for having XML attributes. With format_rss_channel(), you can only do <key>value</key> style tags. The attributes are useful for example for doing openSearch extensions to RSS/Atom.
The way the code was written, the two functions had their own code for converting the given $args array into XML. So I took the more flexible version format_rss_item() and moved it to new a function format_xml_tags() which is now used from both. I also tweaked it to support nesting of tags (one line change).
The best part is that it's a generic function for output clean, safe XML that can be reused by contrib.
It should definitely go into HEAD, but the lack of rss channel attributes is IMO a bug in the 4.7 implementation.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | xmlapi_0.diff | 2.55 KB | Steven |
| xmlapi.diff | 1.92 KB | Steven |
Comments
Comment #1
walkah commentedbig fat +1 . yay for more and better xml handling tools in core.
Comment #2
morbus iffSubscribing. Talked to UnConeD about some changes in IRC.
Comment #3
Steven commentedRenamed format_xml_tags() to format_xml_elements() (morbus) and added doxygen for the array format (which should've been there already).
Comment #4
moshe weitzman commentedcool .. could this be used for regular HTML such as needed at http://drupal.org/node/2039 (support arbitrary nesting of lists in theme_item_list())?
Comment #5
Steven commentedForgot to mark as fixed when committed.
Comment #6
(not verified) commented