0

i have a problem with this script, problem being i assume it the hyphen in the node names it throwing the xmlreader out i have to use xml reader instead of simplexml as the file is 1gb and our server is only 1gb, anyway this is the xml:

 <dataroot>
   <Hotel_All_Active_x0020_08-29-12>
     ...................
   </Hotel_All_Active_x0020_08-29-12>
   <Hotel_All_Active_x0020_08-29-12>
     ...................
   </Hotel_All_Active_x0020_08-29-12>
 </dataroot> 

then this is the script im trying to parse with if i run the script i get one result back, i know i could perform a transformation on the xml but as we may have to go through the process every other week i want to keep it as simple and direct as possible, i know in simple xml you can just encase in curly brackets and wondered if there is the same problem.

hears the code thats meant to cycle through all the Hotel_All_Active_x0020_08-29-12:

$reader = new XMLReader();

$reader->open("Hotel_All.xml");

$dom = new DomDocument();

  while ($reader->read() && $reader->name !== 'Hotel_All_Active_x0020_08-29-12');

  while ($reader->name === 'Hotel_All_Active_x0020_08-29-12')
  {
   $node = new SimpleXMLElement($reader->readOuterXml());

   $nodename = $node->name;

   $reader->next('Hotel_All_Active_x0020_08-29-12');
  }

but it never moves on to the next element, is there an easy way to deal with the illegal characters in xmlreader or is the only option to use xsl to change the names?

this is not the complete script but i know up until $reader->next(); everything is fine

dom
  • 254
  • 1
  • 4
  • 18
  • To understand what your code is doing: Why you loop over all elements where the name is strictly not `Hotel_All_Active_x0020_08-29-12` and then try to loop over all elements with the exact same name? – eddipedia Sep 03 '12 at 17:35
  • i may have sussed it, this allways happens asking questions then it comes to me, the problem is the names they all have the same names but im guessing because there illegal characters it wont work but ive found an easyer way to convert the names to a value that xmlreader can handle without writing any code.# – dom Sep 03 '12 at 17:40

0 Answers0