I have a PHP file that gets an XML files from a HTML form. The PHP files needs to generate a new HTML file containing a table with the the data retrived from the XML file. I was able to this this properly (using expat). However, before adding the data to the table, I would need to sort the data based on one of the XML elements in my file. This is where my problem begins. I'm trying to build an array from by XML file using the following code:

 $xmlFile = $_GET["xmlFile"];
 $p = xml_parser_create();
 xml_parse_into_struct($p, $xmlFile, $vals, $index);
 echo "First array <br>";
 echo "<br>Second Array<br>";

However, both $vals and $index are empty! Any suggestions on what is wrong and how to fix it? I'm fairly new to PHP.

Member Avatar

Show the xml content

does $_GET["xmlFile"] contan the filename/url of the xml or the actual xml-content?

We need to see your target xml file. It all depends on your xml file structure. There are several methods in parsing xml file. It all depends on the target document.