I want to extract all comments below a specific node within an XML document, using PHP. I have tried both the SimpleXML and DOMDocument methods, but I keep getting blank outputs. Is there a way to retrieve comments from within a document without having to resort to Regex?
Share
SimpleXML cannot handle comments, but the DOM extension can. Here’s how you can extract all the comments. You just have to adapt the XPath expression to target the node you want.