Hi,

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);
 xml_parser_free($p);
 echo "First array <br>";
 print_r($vals);
 echo "<br>Second Array<br>";
 print_r($index);

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

Recommended Answers

All 3 Replies

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.