xpath查找xml节点和节点属性的值
时间:2021-07-01 10:21:17
帮助过:19人阅读
xpath查找xml节点和节点属性的值
- $xml = "
- world
- ";
- 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');
|