How to tell apart SimpleXML objects representing element and attribute?

后端 未结 6 1014
猫巷女王i
猫巷女王i 2020-12-04 00:30

I need to print arbitrary SimpleXML objects in a specific manner, with special handling of attribute nodes.

The problem is that SimpleXML elements and attri

6条回答
  •  独厮守ぢ
    2020-12-04 00:56

    Using what palako pointed out, a function like this might work:

    function is_attribute($node) {
        return !($node->asXML()[0] == "<")
    }
    

提交回复
热议问题