Use a regular expression to obtain the data token in xml.
Obtain the data Record ItemId = "1" Value20110524/Value/Item ItemId = "7" Value13.82/Value/Item ItemId = "8" Value13.94/Value/Item ItemId =" 9 "Value13.79/Value/Item ItemId =" 11 "Value13.85/Value/Item/Record RecordItemId =" 1 "Value20110525
Obtain data in xml using a regular expression
20110524
13.82
13.94
13.79
13.85
20110525
13.82
13.86
13.58
13.60
This is part of the xml file. It is to extract the values following the value tag one by one from it. It is better to know several records.
It can be applied to a defined function, such
Function value ($ a, $ B, $ c, $ d, $ n ){
.......
}
For (I = 1; I <(number of records); I ++ ){
Value ($ a, $ B, $ c, $ d, $ I );
}
Cycles:
First Implementation of value (13.82, 13.94, 13.79, 13.85, 1)
Second Implementation value (13.82, 13.86, 13.58, 13.60, 2)
------ Solution ----------------------
Php provides a dedicated Method
$s =<<< XML
20110524
13.82
13.94
13.79
13.85
20110525
13.82
13.86
13.58
13.60
XML;
$x = simplexml_load_string("
$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
)
------ Solution ----------------------
$ Count = preg_match_all ('/
(. + ?) <\/Record>/is ', $ str, $ m );
Echo $ count;
Preg_match_all ('/
(. + ?) <\/Value>/is ', $ str, $ values );
Echo"
";
Print_r ($ values [1]);
Echo "<[this article comes from the Internet (http://www.68idc.cn)]/pre> ";
/*
2
Array
(
[0] = & gt; 20110524
[1] => 13.82.
[2] => 13.94.
[3] = & gt; 13.79
[4] = & gt; 13.85
[5] = & gt; 20110525
[6] = & gt; 13.82
[7] = & gt; 13.86
[8] = & gt; 13.58
[9] = & gt; 13.60
)
*/