我正在使用以下代码从在线XML Feed中获取结果...
<?php
$url="http://www.domain.com/xmlapi-im/years.asp";
$xmlinfo = simplexml_load_file($url);
echo '<pre>';
var_dump($xmlinfo);
echo '</pre>';
?>
结果就是这样......
object(SimpleXMLElement)#1 (1) {
["table"]=>
array(52) {
[0]=>
object(SimpleXMLElement)#2 (1) {
["year"]=>
string(4) "2014"
}
[1]=>
object(SimpleXMLElement)#3 (1) {
["year"]=>
string(4) "2013"
}
[2]=>
object(SimpleXMLElement)#4 (1) {
["year"]=>
string(4) "2012"
}
[3]=>
object(SimpleXMLElement)#5 (1) {
["year"]=>
string(4) "2011"
}
[4]=>
object(SimpleXMLElement)#6 (1) {
["year"]=>
string(4) "2010"
}
[5]=>
object(SimpleXMLElement)#7 (1) {
["year"]=>
string(4) "2009"
}
[6]=>
object(SimpleXMLElement)#8 (1) {
["year"]=>
string(4) "2008"
}
[7]=>
object(SimpleXMLElement)#9 (1) {
["year"]=>
string(4) "2007"
}
[8]=>
object(SimpleXMLElement)#10 (1) {
["year"]=>
string(4) "2006"
}
[9]=>
object(SimpleXMLElement)#11 (1) {
["year"]=>
string(4) "2005"
}
[10]=>
object(SimpleXMLElement)#12 (1) {
["year"]=>
string(4) "2004"
}
[11]=>
object(SimpleXMLElement)#13 (1) {
["year"]=>
string(4) "2003"
}
[12]=>
object(SimpleXMLElement)#14 (1) {
["year"]=>
string(4) "2002"
}
[13]=>
object(SimpleXMLElement)#15 (1) {
["year"]=>
string(4) "2001"
}
[14]=>
object(SimpleXMLElement)#16 (1) {
["year"]=>
string(4) "2000"
}
[15]=>
object(SimpleXMLElement)#17 (1) {
["year"]=>
string(4) "1999"
}
[16]=>
object(SimpleXMLElement)#18 (1) {
["year"]=>
string(4) "1998"
}
[17]=>
object(SimpleXMLElement)#19 (1) {
["year"]=>
string(4) "1997"
}
[18]=>
object(SimpleXMLElement)#20 (1) {
["year"]=>
string(4) "1996"
}
[19]=>
object(SimpleXMLElement)#21 (1) {
["year"]=>
string(4) "1995"
}
[20]=>
object(SimpleXMLElement)#22 (1) {
["year"]=>
string(4) "1994"
}
[21]=>
object(SimpleXMLElement)#23 (1) {
["year"]=>
string(4) "1993"
}
[22]=>
object(SimpleXMLElement)#24 (1) {
["year"]=>
string(4) "1992"
}
[23]=>
object(SimpleXMLElement)#25 (1) {
["year"]=>
string(4) "1991"
}
[24]=>
object(SimpleXMLElement)#26 (1) {
["year"]=>
string(4) "1990"
}
[25]=>
object(SimpleXMLElement)#27 (1) {
["year"]=>
string(4) "1989"
}
[26]=>
object(SimpleXMLElement)#28 (1) {
["year"]=>
string(4) "1988"
}
[27]=>
object(SimpleXMLElement)#29 (1) {
["year"]=>
string(4) "1987"
}
[28]=>
object(SimpleXMLElement)#30 (1) {
["year"]=>
string(4) "1986"
}
[29]=>
object(SimpleXMLElement)#31 (1) {
["year"]=>
string(4) "1985"
}
[30]=>
object(SimpleXMLElement)#32 (1) {
["year"]=>
string(4) "1984"
}
[31]=>
object(SimpleXMLElement)#33 (1) {
["year"]=>
string(4) "1983"
}
[32]=>
object(SimpleXMLElement)#34 (1) {
["year"]=>
string(4) "1982"
}
[33]=>
object(SimpleXMLElement)#35 (1) {
["year"]=>
string(4) "1981"
}
[34]=>
object(SimpleXMLElement)#36 (1) {
["year"]=>
string(4) "1980"
}
[35]=>
object(SimpleXMLElement)#37 (1) {
["year"]=>
string(4) "1979"
}
[36]=>
object(SimpleXMLElement)#38 (1) {
["year"]=>
string(4) "1978"
}
[37]=>
object(SimpleXMLElement)#39 (1) {
["year"]=>
string(4) "1977"
}
[38]=>
object(SimpleXMLElement)#40 (1) {
["year"]=>
string(4) "1976"
}
[39]=>
object(SimpleXMLElement)#41 (1) {
["year"]=>
string(4) "1975"
}
[40]=>
object(SimpleXMLElement)#42 (1) {
["year"]=>
string(4) "1974"
}
[41]=>
object(SimpleXMLElement)#43 (1) {
["year"]=>
string(4) "1973"
}
[42]=>
object(SimpleXMLElement)#44 (1) {
["year"]=>
string(4) "1972"
}
[43]=>
object(SimpleXMLElement)#45 (1) {
["year"]=>
string(4) "1971"
}
[44]=>
object(SimpleXMLElement)#46 (1) {
["year"]=>
string(4) "1970"
}
[45]=>
object(SimpleXMLElement)#47 (1) {
["year"]=>
string(4) "1969"
}
[46]=>
object(SimpleXMLElement)#48 (1) {
["year"]=>
string(4) "1968"
}
[47]=>
object(SimpleXMLElement)#49 (1) {
["year"]=>
string(4) "1967"
}
[48]=>
object(SimpleXMLElement)#50 (1) {
["year"]=>
string(4) "1966"
}
[49]=>
object(SimpleXMLElement)#51 (1) {
["year"]=>
string(4) "1965"
}
[50]=>
object(SimpleXMLElement)#52 (1) {
["year"]=>
string(4) "1964"
}
[51]=>
object(SimpleXMLElement)#53 (1) {
["year"]=>
string(4) "1955"
}
}
}
我正在尝试从“year”中获取值并将其放入单个数组中,稍后我将在foreach循环中使用它。我不确定如何从这个遥远的地方抓住价值,我有点难过。
非常感谢任何帮助!