Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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_Xml - Fatal编程技术网

Php 筛选xml数据不起作用

Php 筛选xml数据不起作用,php,xml,Php,Xml,我使用外部xml,这是可行的,但我有另一个问题。在我的_构造中,我有$elem,它负责过滤xml数据。但它不起作用。请帮忙。我不知道怎么咬它 class Property { public $xmlClass; public $array = []; public $elem = ''; public function __construct($xml,$elem) { $this->xmlClass=$xml; foreach($x

我使用外部xml,这是可行的,但我有另一个问题。在我的_构造中,我有$elem,它负责过滤xml数据。但它不起作用。请帮忙。我不知道怎么咬它

class  Property {
    public $xmlClass;
    public $array = [];
    public $elem = '';
    public function __construct($xml,$elem) {
    $this->xmlClass=$xml;

      foreach($xml->list->film->$elem as $result) {
        $array = array_push($result);

      }
   }
}




$result_scenario = new Property($xml,'scenario');
print_r($result_scenario);

array\u push
方法不是这样工作的

您需要将数组作为第一个参数传递,而不是传递要在其上推送的元素。在您的例子中,它将是
array\u push($this->array,$result)。函数返回数组中新的元素数

请参阅此处的文档

,而不是说“它不工作”,您应该输入有关正在发生的事情的信息。例如,您是否收到错误消息?