Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


WordPress plugin to handle XML remote feed.

Hello there,

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">
            <city_state_country>Cd. Juarez, CH MEX</city_state_country>
            <city_state_country>Marine, MN USA</city_state_country>

1 Answer

Shane Oliver
Shane Oliver
19,950 Points

PHP has a parser for XML inbuilt so you could do something like

    $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

You're right! I think using JSON would be a much better way to feed this kind of information to external websites, specially to embed it in a table. However, as I said, this feed is being generated from other source that I can't access or change.

How about if I threat this as a RSS feed? Do you think it will be easier that way? Although I wanted to show it inside a table, I think if I achieve to show it as a chronological feed will be fine, too.

In that case, when I use a RSS reader, how can I do to get the information inside those custom tags like: <city_state_country>, <gender>, <rank>, etc...? The regular readers are just recognising the <title> tag.