I have two pages.
Page 1: just contains the form with a method=get and two text fields.
Page 2: has the xml parser and it works just find as it retrieves the xml results in HTML format.
Page 2 Code:
<?php
$file = "http://www.somesite.com/xml_api?q=" . $_GET["q"] . "&l=" . $_GET["l"] . "";
function contents($parser, $data){
echo $data;
}
function startTag($parser, $data){
echo "<b>";
}
function endTag($parser, $data){
echo "</b><br />";
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_parser, "contents");
$fp = fopen($file, "r");
$data = fread($fp, 80000);
if(!(xml_parse($xml_parser, $data, feof($fp)))){
die("Error on line " . xml_get_current_line_number($xml_parser));
}
xml_parser_free($xml_parser);
fclose($fp);
?>
The problem is that i want to manipulate some of the xml tags being retrieved. For example one of the xml tags is a URL and i want to hyperlink it with a <a href..> tag but on the code above i dont know how to find that xml tag. I know that the xml tag for the URL is <url>sometext</url>.
Please help me figure this out. Thanks!