How to get a remote XML, extract the data and show them on my PHP page?
I need to extract data from this XML-feed: http://ads-cdn.unibet.com/orval/feed/PokerTournaments.xml
And make the extracted and formatted data appear on a PHP page, a page I will include either via PHP or as IFRAME into a wordpress page.
I have tried DOM and simple xml, but it will not work, I just get a blank page. The only thing I got to work is in the "code" below, but here it only shows 3 records, and I dont know why?? I want to determine the number of records shown.
I have also made a XSL-file for transformation. This file is pasted below the PHP code in the "code" field. Togetehr with a PHP file I hoped it would parse the XML-file, but all I got as a BLANK window. Can you see what is wrong with this?
<?php// read xml file into string$text = file_get_contents("http://ads-cdn.unibet.com/orval/feed/PokerTournaments.xml");if(!$text) {die("ERROR: Unable to read file");}// parse the xml into structure$p = xml_parser_create();xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);xml_parse_into_struct($p, $text, $vals, $index);xml_parser_free($p);// read data of interest from structure into array:for($i=0; $i<$index['Tournament'][1]; $i++){foreach(array('Name', 'GameType', 'BuyInAmount', 'date', 'Status') as $key){$data[$i][$key] = $vals[$index[$key][$i]]['value'];}}// output HTML:foreach($data as $val){echo <<<XML<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />// I KNOW THE FORMATTING BELOW IS SICK, JUST WANTED TO TEST IF IT WORKED<h3><a href="{$val['BuyInAmount']}" title="{$val['Name']}">{$val['Name']}</a></h3><p>{$val['date']}</p><a href="{$val['BuyInAmount']}" title="{$val['Name']}"><small>{$val['GameType']}</small></a>XML;}?>THE XSL:<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="PokerTournaments.xml" --><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> <!ENTITY copy "©"> <!ENTITY reg "®"> <!ENTITY trade "™"> <!ENTITY mdash "—"> <!ENTITY ldquo "“"> <!ENTITY rdquo "”"> <!ENTITY pound "£"> <!ENTITY yen "¥"> <!ENTITY euro "€">]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/><xsl:template match="/"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>Kommende pokerturneringer</title></head><body><table width="700" border="1" cellspacing="2" cellpadding="3"> <tr> <td>Turneringsnavn</td> <td>Pokertype</td> <td>Innstegspris</td> <td>Registrerte spillere</td> <td>Status</td> <td>Startdato</td> </tr> <xsl:for-each select="Poker/Tournament"> <tr> <td><xsl:value-of select="Name"/></td> <td><xsl:value-of select="GameType"/></td> <td><xsl:value-of select="BuyInAmount"/></td> <td><xsl:value-of select="RegisteredPlayers"/></td> <td><xsl:value-of select="Status"/></td> <td><xsl:value-of select="StartDate"/></td> </tr> </xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>