Php SimpleXMLElement从特定节点获取值

Php SimpleXMLElement从特定节点获取值,php,arrays,xml,Php,Arrays,Xml,我试图使用simplexml从html字符串中获取标记内的特定值。以下是simplexml示例输出: SimpleXMLElement Object ( [comment] => SimpleXMLElement Object ( ) [div] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array (

我试图使用simplexml从html字符串中获取标记内的特定值。以下是simplexml示例输出:

    SimpleXMLElement Object (

    [comment] => SimpleXMLElement Object ( ) 

    [div] => Array ( 

        [0] => SimpleXMLElement Object (

             [@attributes] => Array (

                 [class] => col left 

             ) 

             [mod] => name 
        ) 

        [1] => SimpleXMLElement Object ( 

            [@attributes] => Array ( 

                [class] => col right ) 

                [mod] => name 

        ) 

    ) 

 )

我需要的是只从[mod]节点提取值(和键,如果可能的话),而不管字符串中有多少div或其他元素,并将值分配给数组。

在PHP中,是否不可能在所有多维数组中搜索特定键并返回de值?我已经用不同的函数尝试了一百万种方法,但到目前为止没有成功。在PHP中,是否不可能在所有多维数组中搜索特定的键并返回de值?我已经用不同的函数尝试了一百万种方法,但到目前为止没有运气。