时间:2021-07-01 10:21:17 帮助过:8人阅读
不一定需要正则表达式,只要能获取xml的数据,能够使用到函数里面就可以的。。谢谢各位大神了!
php 提供了专用方法
$s =<<< XML20110524 13.82 13.94 13.79 13.85 XML;$x = simplexml_load_string(" 20110525 13.82 13.86 13.58 13.60 $s ");foreach($x->Record as $node) { $t = array(); foreach($node->Item as $v) $t[] = current($v->Value); print_r($t);}
Array( [0] => 20110524 [1] => 13.82 [2] => 13.94 [3] => 13.79 [4] => 13.85)Array( [0] => 20110525 [1] => 13.82 [2] => 13.86 [3] => 13.58 [4] => 13.60)
$count=preg_match_all('/(.+?)<\/Record>/is',$str,$m);echo $count;preg_match_all('/ (.+?)<\/Value>/is',$str,$values);echo " ";print_r($values[1]);echo "";/*2Array( [0] => 20110524 [1] => 13.82 [2] => 13.94 [3] => 13.79 [4] => 13.85 [5] => 20110525 [6] => 13.82 [7] => 13.86 [8] => 13.58 [9] => 13.60)*/
谢谢楼上的两位大神,问题按照你们的方法已经解决了~~嘿嘿