<p>I like the XMLReader class for it's simplicity and speed.  But I like the xml_parse associated functions as it better allows for error recovery.  It would be nice if the XMLReader class would throw exceptions for things like invalid entity refs instead of just issuinng a warning.</p>

[{'answer_id': 68580, 'author': 'ctcherry', 'author_id': 10322, 'author_profile': 'https://Stackoverflow.com/users/10322', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://us2.php.net/simplexml" rel="nofollow noreferrer">SimpleXML</a> seems to do a good job for me.</p>\n'}, {'answer_id': 68584, 'author': 'Brent', 'author_id': 10680, 'author_profile': 'https://Stackoverflow.com/users/10680', 'pm_score': 0, 'selected': False, 'text': '<p>I mostly stick to SimpleXML, at least whenever PHP5 is available for me.</p>\n\n<p><a href="http://www.php.net/simplexml" rel="nofollow noreferrer">http://www.php.net/simplexml</a></p>\n'}, {'answer_id': 68615, 'author': 'nickf', 'author_id': 9021, 'author_profile': 'https://Stackoverflow.com/users/9021', 'pm_score': 3, 'selected': True, 'text': '<p>I\'d avoid SimpleXML if you can. Though it looks very tempting by getting to avoid a lot of "ugly" code, it\'s just what the name suggests: simple. For example, it can\'t handle this:</p>\n\n<pre><code>&lt;p&gt;\n    Here is &lt;strong&gt;a very simple&lt;/strong&gt; XML document.\n&lt;/p&gt;\n</code></pre>\n\n<p>Bite the bullet and go to the DOM Functions. The power of it far outweighs the little bit extra complexity. If you\'re familiar at all with DOM manipulation in Javascript, you\'ll feel right at home with this library.</p>\n'}, {'answer_id': 69523, 'author': 'Chaoley', 'author_id': 10986, 'author_profile': 'https://Stackoverflow.com/users/10986', 'pm_score': 1, 'selected': False, 'text': '<p>There are at least four options when using PHP5 to parse XML files. The best option depends on the complexity and size of the XML file.</p>\n\n<p>There’s a very good 3-part article series titled ‘<a href="http://www.ibm.com/developerworks/xml/library/x-xmlphp1.html" rel="nofollow noreferrer">XML for PHP developers</a>’ at IBM developerWorks.</p>\n\n<p>“Parsing with the DOM, now fully compliant with the W3C standard, is a familiar option, and is your choice for complex but relatively small documents. SimpleXML is the way to go for basic and not-too-large XML documents, and XMLReader, easier and faster than SAX, is the stream parser of choice for large documents.”</p>\n'}, {'answer_id': 77607, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>SimpleXML and DOM work seamlessly together, so you can use the same XML interacting with it as SimpleXML or DOM.</p>\n\n<p>For example:</p>\n\n<pre><code>$simplexml = simplexml_load_string("&lt;xml&gt;&lt;/xml&gt;");\n$simplexml-&gt;simple = "it is simple.";\n\n$domxml = dom_import_simplexml($simplexml);\n$node = $domxml-&gt;ownerDocument-&gt;createElement("dom", "yes, with DOM too.");\n$domxml-&gt;ownerDocument-&gt;firstChild-&gt;appendChild($node);\n\necho (string)$simplexml-&gt;dom;\n</code></pre>\n\n<p>You will get the result: </p>\n\n<pre><code>"yes, with DOM too."\n</code></pre>\n\n<p>Because when you import the object (either into simplexml or dom) it uses the same underlining PHP object by reference. </p>\n\n<p>I figured this out when I was trying to correct some of the errors in SimpleXML by extending/wrapping the object.</p>\n\n<p>See <a href="http://code.google.com/p/blibrary/source/browse/trunk/classes/bXml.class.inc" rel="nofollow noreferrer">http://code.google.com/p/blibrary/source/browse/trunk/classes/bXml.class.inc</a> for examples.</p>\n\n<p>This is really good for small chunks of XML (-2MB), as DOM/SimpleXML pull the full document into memory with some additional overhead (think x2 or x3). For large XML chunks (+2MB) you\'ll want to use XMLReader/XMLWriter to parse SAX style, with low memory overhead. I\'ve used 14MB+ documents successfully with XMLReader/XMLWriter.</p>\n'}]
['https://Stackoverflow.com/questions/68565', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']