CodeIgniter Forums
How to Read a Large size --XML File (80MB) PHP/ Codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forum-1.html)
+--- Forum: Lounge (https://forum.codeigniter.com/forum-3.html)
+--- Thread: How to Read a Large size --XML File (80MB) PHP/ Codeigniter (/thread-74421.html)



How to Read a Large size --XML File (80MB) PHP/ Codeigniter - fnbhns - 09-20-2019

Hi ...Everyone...

I am having an issue seems tired and sinking perhaps you can rescue me, Though I am new with this tools PHP/ Codeigniterworking with a large XML file size about 80 MB. If you kindly help me with your code or instructionHow can I open and read this file using XML techniqes ( SAX or Parser )

Thanks you for your kind support in advance and highly waiting for you. Kindly forward in my  Address # fnbhns (A)(T) gmail (DOT)com #


RE: How to Read a Large size --XML File (80MB) PHP/ Codeigniter - ciadmin - 09-20-2019

Not specific to CodeIgniter...
1) I use SimpleXML to read/manipulate XML documents
2) You are likely going to have to increase your memory limit in php.ini; an 80MB XML document will result in a much larger DOM in memory


RE: How to Read a Large size --XML File (80MB) PHP/ Codeigniter - fnbhns - 09-20-2019

(09-20-2019, 01:28 PM)ciadmin Wrote: Not specific to CodeIgniter...
1) I use SimpleXML to read/manipulate XML documents
2) You are likely going to have to increase your memory limit in php.ini; an 80MB XML document will result in a much larger DOM in memory
Thank you so much for your so quickly reply. I am trying with the SimpleXML unfortunately I can not. However i never worked before with XML. If you kindly give me little support, I am trying to upload a XML file then Read the file, If i want i sent few record into SQL.  For your kind view I attached  the function i have written below.
Code:
public function importPro()
        {
           $fileName= $_FILES['xml_file']['name'];
            copy($_FILES['xml_file']['tmp_name'],'./assets/'.$fileName);
            $xmlfile= './assets/'.$fileName;
            $xmlRaw= file_get_contents($xmlfile);  
            $xmlData= $this->simplexml->xml_parse($xmlRaw);         
                      
            foreach($xmlData['product'] as $row)
            {
               // $this->mproduct->insert($row['code'],$row['name'] );
                $this->mproduct->insert($row['id'],$row['author'] );
            }
            $data['productList']= $this->mproduct->findAllProd();
            $this->load->view('product/success',$data);
           
        }

Your little advise could be a great help. Even if you like show your a piece of code how you used simpleXML which could be a great support too......! While i run this program its show below Error and few more line is there.

Code:
A PHP Error was encountered
Severity: Warning

Message: Illegal string offset 'toy'

Filename: libraries/simplexml.php(126) : eval()'d code

Line Number: 1
Sorry to give you trouble. in fact You can save me from a big trouble, otherwise i maybe fired . once again thanks for your kind support.


RE: How to Read a Large size --XML File (80MB) PHP/ Codeigniter - ciadmin - 09-20-2019

A bit dated, but ... https://github.com/jedi-academy/example-simplexml-winter2016