SimpleXML keeps returning content on CDATA element

后端 未结 2 1981
误落风尘
误落风尘 2021-01-26 10:15

So another CDATA returning content question. I\'ve seen many answers, but even though I tried them all, I still get only content.

In more details:

I have an xml

2条回答
  •  旧时难觅i
    2021-01-26 10:29

    I think your example returns 'content' because you are concatenating an element that does not exist

    $element->NewsComponent->ContentItem->DataContent->body->body
    

    with the string 'content' - probably PHP complains that there's no constant with the name content and therefore assumes you meant 'content'.

    Thus my guess is you need to find another way to select an element with a dot in the name.

    (This problem does not appear to be related to CDATA.)

提交回复
热议问题