SimpleXMLElement's capacity


<?php
while($document->read()){
  if('product' === $document->name && $document->nodeType === XMLReader::ELEMENT){
    $product = new stdClass;
    while($document->read()){
      if('product' === $document->name && $document->nodeType === XMLReader::END_ELEMENT){
        
        #fully populated $product is here
        
        break;
      }
      switch($document->nodeType){
        
        case XMLReader::ELEMENT:
          $property = $document->name;
          $product->{$property} = '';
        break;
      
        case XMLReader::TEXT:
          if(null !== $property){
            $product->{$property} = $document->value;
          }
      
        default:
          $property = null;
        break;
      }
    }
  }
}
?>

Is the file valid XML?

I have 40MB of xml data when i tried to load it via SimpleXMLElement , it gave an error:

String could not be parsed as XML

is this because of xml size?

I have no idea. You could try :slight_smile:

the most probable problem with the xml file is it was opened in an editor that could only handle so many lines, DW cuts out at about 97k and save all gets me every time :frowning:

(DW saves what it loaded of the file, and not the whole file)

Nice catch tho Mittineague I missed that until you called it. its late