Here it all is friend :
<?php
$qry = stripslashes($qry);
function status($message) {
return "onMouseOver=\"window.status='$message'; return true;\" onMouseOut=\"window.status=''; return true;\"";
}
function displayResult($resultid, $title, $abstract, $redir, $url) {
global $offset;
$statusbar = status("visit: $url");
echo "<DL>\n<DT><A $statusbar HREF=\"$redir\" target=\"_blank\"><b>".($offset + $resultid).". $title</b></a></DT>";
echo "<DD>$abstract</DD>\n<DD>$url</DD>\n</DL>\n";
}
// handles the attributes for opening tags
// $attrs is a multidimensional array keyed by attribute
// name and having the value of that attribute
function startElement($parser, $name, $attrs=''){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
if ($currenttag == "") { $parenttag = $currenttag; }
$currenttag = $name;
if (count($attrs) > 0) {
foreach($attrs as $keys) {
// print ($keys);
if ($name == "RESULTSET") {
$resultset = $attrs;
}
if ($name == "RESULT") {
$resultid = $attrs["ID"]+1;
//print ($attrs["ID"]);
}
}
}
}
// $current_tag lets us know what tag we are currently
// dealing with - we use that later in the characterData
// function.
function endElement($parser, $name, $attrs=''){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
global $Atitle, $Aabstract, $Aredir, $Aurl;
if ($name == "RESULT") {
//displayResult($resultid, $title, $abstract, $redir, $url);
array_push($Atitle, $title);
array_push($Aabstract, $abstract);
array_push($Aredir, $redir);
array_push($Aurl, $url);
$title = "";
$abstract = "";
$redir = "";
$url = "";
}
$currenttag = "";
}
// this function is passed data between elements
function characterData($parser, $data){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
//$data =~ s/£/£/;
if (($currenttag == "TITLE") && ($data != "\n")) { $title = $title . $data; }
if (($currenttag == "ABSTRACT") && ($data != "\n")) { $abstract = $abstract . $data; }
if (($currenttag == "URL") && ($data != "\n")) { $url = $url . $data; }
if (($currenttag == "REDIR") && ($data != "\n")) { $redir = $redir . $data; }
}
$nres == 0 ? $nres = 10 : 0;
$nfs == "" ? $nfs = 3 : 0;
$offset == "" ? $offset = 0: 0;
$details == "" ? $details = 1 : 0;
$Atitle = array();
$Aabstract = array();
$Aredir = array();
$Aurl = array();
$xml_feed = "http://www.mirago.co.uk/scripts/xmlhandler.aspx?";
$xml_feed .= "&qry=" . urlencode($qry);
$xml_feed .= "&ass=" . $ass;
$xml_feed .= "&details=". $details;
$xml_feed .= "&nres=" . $nres;
$xml_feed .= "&offset=" . $offset;
$xml_feed .= "&nfs=" . $nfs;
$xml_feed .= "&fsonly=" . $fsonly;
$pagelink = getenv("SCRIPT_NAME") . "?qry=" . urlencode($qry) . "&ass=$ass&nres=$nres&details=$details&fsonly=$fsonly";
// what are we parsing?
$type = 'ISO-8859-1';
// create our parser
$xml_parser = xml_parser_create($type);
// set some parser options
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $type);
// this tells PHP what functions to call when it finds an element
// these funcitons also handle the element's attributes
xml_set_element_handler($xml_parser, 'startElement','endElement');
// this tells PHP what function to use on the character data
xml_set_character_data_handler($xml_parser, 'characterData');
if (!($fp = fopen($xml_feed, 'r'))) {
die("Could not open $xml_feed for parsing!\n");
}
// loop through the file and parse baby!
while ($data = fread ($fp, 4096)) {
// if (!($data = utf8_encode($data))) {
// echo 'ERROR'."\n";
// }
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf( "XML error: %s at line %d\n\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
?>