Soldato
This is my code:
This is a copy of the remote xml I am trying to parse:
Now when I run my script it errors with:
explode() expects parameter 2 to be string, array given in D:\wamp\www\xpathtest.php on line 9
Now, I assume that the error means that my $result is an array and needs to be a string?
PHP:
<?php
//a XML you want to retrieve
$xml = simplexml_load_file('url.com');
//Find the Second <description> tag and put contents into a string
$result = ($xml->xpath("//description[1]"));
// break $result using the br character as the delimiter
$number = explode('br', $result);
//removes every character & symbol except numbers
$number = preg_replace("/\D/", "", $number);
//print the number on it's own
echo $number;
This is a copy of the remote xml I am trying to parse:
PHP:
<rss version="2.0">
<channel>
<title>football results</title>
<link>
http://url.com
</link>
<description>
football results
</description>
<date>Tue, 24 Jan 2012 19:58:35 GMT</date>
<language>en</language>
<image>
<url>http://url.com/image.jpg</url>
<title>Football fixtures</title>
<link>
http://url.com
</link>
</image>
<lastBuildDate/>
<item>
<title>Football teams</title>
<link>
http://url.com
</link>
<description>
I WANT TO <br>SCRAPE THIS NUMBER</br> <br>IN HERE 5000000</br>
</description>
<pubDate>Tue, 02 Feb 2012 10:40:00 GMT</pubDate>
<guid>999999</guid>
</item>
</channel>
</rss>
Now when I run my script it errors with:
explode() expects parameter 2 to be string, array given in D:\wamp\www\xpathtest.php on line 9
Now, I assume that the error means that my $result is an array and needs to be a string?