x
 
Create New Page

Revision: XML Parsing Tool

Revision from: 15:44, 2 Jun 2008

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} 

Non standard XML data feed

<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} 

RSS data feed

<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 href={item_link} 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} 

Atom data feed

<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} 

Category:EE1

Categories: