Web Hosting Talk







View Full Version : XML parsing problem..


HakonHoy
03-20-2006, 07:19 AM
I have e.g. this xml parse script:

<?
$xml = simplexml_load_file("books.xml");

foreach($xml->Book as $Book) {
echo "
<p><strong>".$Book->BookTitle."</strong><br>
<em>by ".$Book->BookAuthor."</em><br>
(Published by ".$Book->BookPublisher.",
ISBN: ".$Book->BookISBN.")<br>
<font color=red>price:</font> \$".$Book->BookPrice."</p>
<hr noshade>";
}

?>

If I want to get the xml from this web site instead: http://www.dailymail.co.uk/pages/xml/index.html?in_page_id=1779

Is it possible to exclude xml using the script?
e.g.
<title>the Mail online | Football</title>
<description>Team news, match analysis and transfer gossip</description>
<link>http://www.dailymail.co.uk/pages/live/sport/football.html?in_page_id=1779&amp;ito=1490</link> Wich is a constant, that never changes text..

My question is, how can I use a XML parser, and exclude some of the stuff in the xml feed? What code can I use for that?

Burhan
03-20-2006, 08:31 AM
Since its just text, you can use any of the text matching functions or regular expression functions to filter out what you need.

Or, if the tags are always the same, just don't display those tags.