Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to delete xml elements/nodes from xml file larger than available RAM?
    text
    copied!<p>I'm trying to figure out how to delete an element (and its children) from a xml file that is very large in php (latest version).</p> <p>I know I can use dom and simpleXml, but that will require the document to be loaded into memory.</p> <p>I am looking at the XML writer/reader/parser functions and googling, but there seems to be nothing on the subject (all answers recommend using dom or simpleXml). That cannot be correct--am I missing something?</p> <p>The closest thing I've found is this (C#):</p> <blockquote> <p>You can use an XmlReader to sequentially read your xml (ReadOuterXml might be useful in your case to read a whole node at a time). Then use an XmlWriter to write out all the nodes you want to keep. ( <a href="https://stackoverflow.com/questions/9057235/deleting-nodes-from-large-xml-files">Deleting nodes from large XML files</a> )</p> </blockquote> <p>Really? Is that the approach? I have to copy the entire huge file?</p> <p>Is there really no other way?</p> <h1>One approcah</h1> <p>As suggested,</p> <p>I could read the data using phps XML reader or parser, possibly buffer it, and write/dump+append it back to a new file.</p> <p><strong>But is this approach really practical?</strong></p> <p>I have experience with splitting huge xml files into smaller pieces, basically using suggested method, and it took a very long time for the process to finish.</p> <p>My dataset isn’t currently big enough to give me an idea on how this would work out. I could only assume that the results will be the same (a very slow process).</p> <p>Does anybody have experience of applying this in practice?</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