php SimpleXML check if a child exists

后端 未结 16 2202
粉色の甜心
粉色の甜心 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:06

    Name Spaces

    Be aware that if you are using name spaces in your XML file you will need to include those in your function calls when checking for children otherwise it will return ZERO every time:

    if ($XMLelement->children($nameSpace,TRUE)->count()){
        //do something here 
    }
    

提交回复
热议问题