Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a couple ways to process large documents incrementally, so that you do not need to load the entire structure into memory at once. In either case, yes, you will need to write back out the elements that you wish to keep and omit those you want to remove.</p> <ol> <li><p>PHP has an <a href="http://php.net/manual/en/book.xmlreader.php" rel="nofollow"><code>XMLReader</code> implementation of a pull parser</a>. An <a href="http://en.wikipedia.org/wiki/XML#Pull_parsing" rel="nofollow">explanation</a>:</p> <blockquote> <p>A pull parser creates an iterator that sequentially visits the various elements, attributes, and data in an XML document. Code which uses this iterator can test the current item (to tell, for example, whether it is a start or end element, or text), and inspect its attributes (local name, namespace, values of XML attributes, value of text, etc.), and can also move the iterator to the next item. The code can thus extract information from the document as it traverses it.</p> </blockquote></li> <li><p>Or you could use <a href="http://php.net/manual/en/book.xml.php" rel="nofollow">the SAX XML Parser</a>. <a href="http://en.wikipedia.org/wiki/XML#Simple_API_for_XML" rel="nofollow">Explanation</a>:</p> <blockquote> <p>Simple API for XML (SAX) is a lexical, event-driven interface in which a document is read serially and its contents are reported as callbacks to various methods on a handler object of the user's design. SAX is fast and efficient to implement, but difficult to use for extracting information at random from the XML, since it tends to burden the application author with keeping track of what part of the document is being processed.</p> </blockquote></li> </ol> <p>A lot of people prefer the pull method, but either meets your requirement. Keep in mind that large is relative. If the document fits in memory, then it will almost always be easier to use the DOM. But for really, really large documents that simply might not be an option.</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