PHP xpath查找xml节点和节点属性的值
xpath查找xml节点和节点属性的值 xpath查找xml节点和节点属性的值**[PHP]代码**[代码片段(23行)]
xpath查找xml节点和节点属性的值
[PHP]代码
<?php $xml = " <node> <title src='hello'>world</title> </node> "; function get_data_from_xml($res_data,$node) { $xml = simplexml_load_string($res_data); $result = $xml->xpath($node); while(list( , $node) = each($result)) { return $node; } } // 'hello world'; echo get_data_from_xml($xml, '/node/title/@src[.]'), ' ' , get_data_from_xml($xml, '/node/title');
收藏文章
精彩图集
精彩文章