Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.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 Symfony爬虫从foreach中的getted childs获取子节点?_Php_Xml_Symfony_Parsing_Web Crawler - Fatal编程技术网

Php Symfony爬虫从foreach中的getted childs获取子节点?

Php Symfony爬虫从foreach中的getted childs获取子节点?,php,xml,symfony,parsing,web-crawler,Php,Xml,Symfony,Parsing,Web Crawler,我和你一起工作 XML看起来像: <Tours> <Tour id="1"> <Termins> <Termin> ... 但我想找到这样的方法来使用爬虫程序:(主要的一点是没有来自“top”的选择器,但来自元素witch,它已经在foreach中了) 此时,当您通过爬虫时,您将得到一个DOMNode数组。然后可以为该子文档创建新的爬网程序 foreach

我和你一起工作

XML看起来像:

<Tours>
    <Tour id="1">
        <Termins>
            <Termin>
            ...
但我想找到这样的方法来使用爬虫程序:(主要的一点是没有来自“top”的选择器,但来自元素witch,它已经在foreach中了)

此时,当您通过
爬虫
时,您将得到一个
DOMNode
数组。然后可以为该子文档创建新的爬网程序

foreach ($crawler->filter('tour') as $tour) {
    $tourCrawler = new Crawler($tour);
    $tourCrawler->attr('id'); // 1...
    foreach ($tourCrawler->filter('termin') as $termin) {
        // Access nodes or create further crawlers
    } 
}
        foreach ($crawler->children() as $tour) {
            foreach($tour->first('Termins')->children() as $termin)
foreach ($crawler->filter('tour') as $tour) {
    $tourCrawler = new Crawler($tour);
    $tourCrawler->attr('id'); // 1...
    foreach ($tourCrawler->filter('termin') as $termin) {
        // Access nodes or create further crawlers
    } 
}