Welcome to the Treehouse Community
Looking to learn something new?
WordPress plugin to handle XML remote feed.
I have an URL link to a sport ranking feed that I want to embed in a table inside my WordPress site. However, the feed link contains an auto-generated XML, and I was looking quite a lot for plugin that could let me handle this type of format, because It is generated from a third party and I can not modify the XML, so I need to fit my site to it. There are a few that do something similar (i.e. TablePress), but they don't work with XML files.
It seems that I need to code my own plugin for that. Could anyone please, suggest me how to start doing it and what tools and knowledge do I need?
I started to watch the videos about writing a plugin in wordpress. But I think I will need something else in addition.
Thanks in advance....
The XML looks like:
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <item> <title>PlayerName01</title> <R2_UID>49373</R2_UID> <city_state_country>Cd. Juarez, CH MEX</city_state_country> <gender>Male</gender> <player_image></player_image> <rank>1</rank> <ranking_points>13220</ranking_points> <advantage>3495</advantage> <events_played>11</events_played> </item> <item> <title>PlayerName02</title> <R2_UID>32507</R2_UID> <city_state_country>Marine, MN USA</city_state_country> <gender>Male</gender> <player_image></player_image> <rank>2</rank> <ranking_points>9725</ranking_points> <advantage>2145</advantage> <events_played>11</events_played> </item> ... ... ... ... </channel> </rss>
Shane Oliver19,950 Points
PHP has a parser for XML inbuilt so you could do something like
<?php $xml = simplexml_load_file( 'URL of the awesome API that returns XML instead of JSON' ) or die ( 'Error: Your object was not created' ); // add your code to extract that data from your xml object ?>