Note that there are some explanatory texts on larger screens.

plurals
  1. POXMLReader - Blank Page With No Errors
    text
    copied!<p>I'm trying to get the data from an XML file into an array so that I can import it via 'Magmi'. Using the following code, I'm working with a 3.6GB XML file.</p> <pre><code>&lt;?php $z = new XMLReader; $z-&gt;open('wpcatsub.xml'); $doc = new DOMDocument; // move to the first &lt;App /&gt; node while ($z-&gt;read() &amp;&amp; $z-&gt;name !== 'App'); // now that we're at the right depth, hop to the next &lt;App/&gt; until the end of the tree while ($z-&gt;name === 'App') { // either one should work //$node = new SimpleXMLElement($z-&gt;readOuterXML()); $node = simplexml_import_dom($doc-&gt;importNode($z-&gt;expand(), true)); // now you can use $node without going insane about parsing var_dump($node-&gt;element_1); // go to next &lt;product /&gt; $z-&gt;next('App'); } ?&gt; </code></pre> <p>When I load the PHP file, no errors appear -- the page is just blank. My XML data structure is below...</p> <pre><code>&lt;App action="A" id="1"&gt; &lt;BaseVehicle id= "17491"/&gt; &lt;Note&gt;&lt;![CDATA[License Plate Lamp]]&gt;&lt;/Note&gt; &lt;Qty&gt;.000&lt;/Qty&gt; &lt;PartType id= "10043"/&gt; &lt;Part&gt;W0133-1620896&lt;/Part&gt; &lt;Product&gt; &lt;PartNumber&gt;W0133-1620896&lt;/PartNumber&gt; &lt;BrandID&gt;OES&lt;/BrandID&gt; &lt;BrandDescription&gt;&lt;![CDATA[Genuine]]&gt;&lt;/BrandDescription&gt; &lt;WorldpacCategoryID&gt;P9032&lt;/WorldpacCategoryID&gt; &lt;Price&gt;29.85&lt;/Price&gt; &lt;ListPrice&gt;33.17&lt;/ListPrice&gt; &lt;Available&gt;Y&lt;/Available&gt; &lt;OEFlag&gt;OEM&lt;/OEFlag&gt; &lt;Weight&gt;.10&lt;/Weight&gt; &lt;Height&gt;.7&lt;/Height&gt; &lt;Width&gt;4.4&lt;/Width&gt; &lt;Length&gt;4.4&lt;/Length&gt; &lt;SellingIncrement&gt;1&lt;/SellingIncrement&gt; &lt;Popularity&gt;D&lt;/Popularity&gt; &lt;ImageURL&gt;&lt;![CDATA[http://img.eautopartscatalog.com/live/W01331620896OES.JPG]]&gt;&lt;/ImageURL&gt; &lt;ThumbURL&gt;&lt;![CDATA[http://img.eautopartscatalog.com/live/thumb/W01331620896OES.JPG]]&gt;&lt;/ThumbURL&gt; &lt;/Product&gt; &lt;ImageURL&gt;&lt;![CDATA[http://img.eautopartscatalog.com/live/W01331620896OES.JPG]]&gt;&lt;/ImageURL&gt; &lt;ThumbURL&gt;&lt;![CDATA[http://img.eautopartscatalog.com/live/thumb/W01331620896OES.JPG]]&gt;&lt;/ThumbURL&gt; &lt;/App&gt; </code></pre> <p>Is it stalling because of the size of the file? If so, isn't XMLReader supposed to work for large XML files? If nothing else, what other options would I have?</p> <p>I suppose I could load the XML data into a database if needed and then use SELECT queries to build the array for the MAGMI import. Though I'm not sure how to import an XML file into a SQL database. If need be, I'll be happy to get guidance with that.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload