note 85414 added to ref.simplexml

From: Date: Fri, 29 Aug 2008 01:55:21 +0000
Subject: note 85414 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-143963@lists.php.net to get a copy of this message
While SimpleXML is a powerful tool, developers using it to process and handle large XML documents & strings should take into careful consideration its memory usage requirements. SimpleXML requires the entire XML tree to be available prior to any processing actions on that tree -- this requires the entire tree to be in memory. Ok for a 40kb XML file but when dealing with > 100MB files you will see performance degradation, especially if you have a busy server. An alternative to processing large XML files is the XMLReader class, which operates in streaming mode, of which an excellent tutorial is presented here: http://www.ibm.com/developerworks/library/x-pullparsingphp.html XML is an incredibly verbose format. If you are dealing with large data structures, especially in web services, do you you actually need to represent the data as an XML tree? - other serialisation formats such as JSON, Serialised PHP, Google Protocol Buffers (http://code.google.com/p/protobuf/) and even CSV can remarkably reduce processing time, bandwidth and load when dealing with large files. A 110MB XML file can become a 65MB CSV file, with the same data in it, simply because the data identifiers (tags) are only represented once in the entire document. ---- Server IP: 203.88.112.190 Probable Submitter: 58.6.148.157 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/85414 Del: integrated -- https://master.php.net/note/delete/85414/integrated Del: useless -- https://master.php.net/note/delete/85414/useless Del: bad code -- https://master.php.net/note/delete/85414/bad+code Del: spam -- https://master.php.net/note/delete/85414/spam Del: non-english -- https://master.php.net/note/delete/85414/non-english Del: in docs -- https://master.php.net/note/delete/85414/in+docs Del: other reasons-- https://master.php.net/note/delete/85414 Reject -- https://master.php.net/note/reject/85414 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143963) next »