How to retrieve comments from within an XML Document in PHP

后端 未结 4 1734
走了就别回头了
走了就别回头了 2020-12-04 03:04

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 out

4条回答
  •  时光说笑
    2020-12-04 03:51

    If you are using a SAX event driven-parser, the parser should have an event for comments. For example, when using Expat you would implement a handler and set it using:

    void XMLCALL
    XML_SetCommentHandler(XML_Parser p,
                          XML_CommentHandler cmnt);
    

提交回复
热议问题