php SimpleXML check if a child exists

后端 未结 16 2145
粉色の甜心
粉色の甜心 2020-11-27 06:24

A->b->c might exist but c might not exist. How do I check it?

16条回答
  •  無奈伤痛
    2020-11-27 07:05

    After some experimentation, I've discovered that the only reliable method of checking if a node exists is using count($xml->someNode).

    Here's a test case: https://gist.github.com/Thinkscape/6262156

提交回复
热议问题