XML CDATA not returning properly with simplexml_load_string() nor SimpleXMLElement() (PHP)

前端 未结 1 405
梦如初夏
梦如初夏 2021-01-26 03:19

I can pull back any of the non-CDATA fields. But not the summary field. I\'ve exhausted everything i know to try. Below is as close as i could get, with the summary field retu

相关标签:
1条回答
  • 2021-01-26 03:58

    You have a minor problem in your code, simplexml_load_string documentation refers:

    Takes a well-formed XML string and returns it as an object.

    and you're providing a SimpleXMLElement as the first argument. Just replace that line from your code with this one:

    echo (string) 'Summary: ' . simplexml_load_string($entries->summary->children()->asXML(), null, LIBXML_NOCDATA) . "<br />\n";
    
    0 讨论(0)
提交回复
热议问题