I have a problem, I need to display an XML file that is hosted on a remote server. That file I want to display it with CSS and PHP in a file that is already assigned (page-xxxx.php)
I am currently using the following code, however I do not understand very well what I do:
<!-- API here we go!!! -->
<?php
$xmlhd = wp_remote_get('http://www.myurl.com/api/channel.php?type=hd');
$xmlparseado = simplexml_load_string($xmlhd['body']);
?>
The URL specified in the code shows an XML file like this:
<programations>
<channel name="KCBS HD">
<row>
<date>july, 23</date>
<time>06:00</time>
<title><![CDATA[ WKCBS Action News ]]></title>
<description><![CDATA[ Action News, hosted by: Jenn Doe ]]></description>
<imagethumb/>
</row>
<row>
<date>July, 23</date>
<time>06:35</time>
<title><![CDATA[ KCBS Sports Center ]]></title>
<description><![CDATA[ The best scoreS from the Sportscenter stadium, hosted by: Fernando Sobalaprieta ]]></description>
<imagethumb/>
</row>
</channel>
</programations>
What I would like to know is how to show this in front end of a page:
- date
- time
- description
- thumbnail (if exists)
Note:
The contents of the XML is just a sample example and does not necessarily represent the reality: D
In advance, thanks.
function simplexml_load_string(); creates object.
if you try to print_r($xmlparseado), you should get this:
So using iteration, for example for each, you should access each row:
note: this is just example, but you can use its pattern