Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从XML对象提取数据_Php_Simplexml - Fatal编程技术网

Php 从XML对象提取数据

Php 从XML对象提取数据,php,simplexml,Php,Simplexml,如何从该XML对象(某个数组的值)提取数据: Array ( [Title] => SimpleXMLElement Object ( [0] => The Key of Life; A Metaphysical Investigation ) [ASIN] => SimpleXMLElement Object ( [0] => 0982385099 ) ... ) 我对数组进行了如下处理: foreach ($ArrayNam

如何从该XML对象(某个数组的值)提取数据:

Array ( 
   [Title] => SimpleXMLElement Object ( 
      [0] => The Key of Life; A Metaphysical Investigation 
    ) 
   [ASIN] => SimpleXMLElement Object ( [0] => 0982385099 ) ...
 )
我对数组进行了如下处理:

foreach ($ArrayName as $FieldLabel => $FieldValue) { 
     $Variable = $FieldValue[0]....
} 

…但它仍然将整个XML对象作为字段值。我希望它只提取值,而不是整个对象。

所有简单的xml对象都是可迭代的。基本上把任何一个对象看作一个集合,而有些集合恰好包含一个对象

要提取您的价值,请执行以下操作

foreach($title as $item)
{
   $list_of_titles = (string) $item;
}
print_r($list_of_titles);
所以基本上我把每个项目从一个对象输入到一个字符串中