Convert contents of search results to xml file

Hello,

Is there a way that I can convert web pages that display the contents of a search result to an xml file?

For my project (php/html based) the user:

  • logs in to their account
  • enters their search criteria
  • clicks the “Get Results” button.

A php page results page needs to read and display the data in the xml file.
Basically I can figure everything else out except for how to create the initial xml file

Is their a tutorial somewhere on how to do convert search results to an xml file?

Thanks

XML files are basically just a plain text file written in a specific structured style with .xml on the end rather than .txt


$AllResults = array('result text one', 'result text two', 'result text three', 'result text four');
$myFile = "results.xml";  /// open file for writing
$fh = fopen($myFile, 'w') or die("can't open file");

foreach ($AllResults as $SingleResult){ /// loop through the array holding all results pulling out one at atime
$stringData .="<result>".$SingleResult."</result>\
"; /// Insert that result into a string and add all the strings together
}


fwrite($fh, $stringData);/// write the whole string to the file
fclose($fh);// close connection