I have following (very large => 5GB) XML:
<Hotels>
<Hotel>
<Name>Hotel 1</Name>
<City>City 1</City>
<Phone>12345</Phone>
</Hotel>
<Hotel>
<Name>Hotel 2</Name>
<City>City 2</City>
<Phone>67890</Phone>
</Hotel>
...
</Hotels>
And I have a file which defines which fields I want to extract and what their path is:
$root = "/Hotels/Hotel";
$fields = array("HotelName" => "/Name",
"PhoneNumber" => "/Phone");
So the path for HotelName
would be: /Hotels/Hotel/Name
.
Now I want to get the information for every hotel. I cannot create classes for them (like here) because the script has to be dynamically and different XML-files with different definition-files will be passed.
How can I solve this by using the paths, without classes and with low memory usage (=> large files)?
//Edit: Everything is implemented. I just need a way to iterate through the Hotel
and get their values with the paths I have.