I have created a module to parse XML data and turn them into EE variables that you can place in your template . The results can be cached into database for better performance. It is based on XML_Walk from Solspace(www.solspace.com). Special thanks to Mitchell. It is originally written to handle XML data and with a few tweaks, it can also be used to extract data from RSS/Atom feeds.
Full documentation can be viewed once you install the module. Tested on EE 1.6.3.
You can download here:File:ano xml parser 1 0 fixed.zip
See the following examples to get some ideas if this fits your needs. Feel free to modify or customize it to suit your needs. I only implemented it in a way to deal with what I need. You may need to add some other parameters like “limit” or “backspace” or conditions…etc
Simple XML data feed
{exp:ano_xml_parser:fetch source='http://www.w3schools.com/xml/simple.xml' refresh='60' parent_tag='breakfast_menu' child_tag='food'}
Food Name; {food_name} with only {food_calories} calories<br>
Price: {food_price}<br>
Description: {food_description}<br>
<hr>
{/exp:ano_xml_parser:fetch}
<h1>National Weather XML Test</h1>
{exp:ano_xml_parser:fetch source='http://www.weather.gov/data/current_obs/KJFK.xml' refresh='0' parent_tag='_no_root_' child_tag='current_observation'}
Credit: {current_observation_credit}<br/>
Location: {current_observation_location}<br>
<img src='{current_observation_image_url}' title='{current_observation_image_title}'><br>
Temperature: {current_observation_temperature_string}<br>
<hr>
{/exp:ano_xml_parser:fetch}
<h1>Yahoo RSS News Test</h1>
{exp:ano_xml_parser:fetch source='http://rss.news.yahoo.com/rss/topstories' refresh='0' parent_tag='channel' child_tag='item'}
Title: {item_title}<br/>
Description: {item_description}<br>
Link:<a target='_blank'>{item_link}</a><br>
Is Permanent Link?: {item_guid_isPermaLink}<br>
Media Credit: {item_media:credit}<br>
<hr>
{/exp:ano_xml_parser:fetch}
<h1>Expression Engine Developer Atom Test</h1>
{exp:ano_xml_parser:fetch source='http://expressionengine.com/feeds/atom/devblog/' refresh='0' parent_tag='feed' child_tag='entry'}
<u>Title</u>: {entry_title}, by author:{entry_author_name}
<u>Category</u>:{category_term}/{category_label}<br>
<u>Description</u>: {entry_content}<br>
<hr>
{/exp:ano_xml_parser:fetch}
FAQ
1. I receive a notice message about “Undefined variable: tag_value in ....”, what’s wrong?
The parser doesn’t handle gracefully for undefined variables. This happens if you try to access a EE variable that is not formed by the parser via the feed. Double check your EE tag in the template is based on the naming scheme required by the parser. For instance, you’ll need to add the child tag suffix in front of your variable. Eg. child_tag=‘product’, to access the name of the product, you’ll need to use {product_name}, not {name}.
