how to get attribute values from children (HTML) in XPath php : first i had looked for all the elements i need, now i am trying to get attributed values from the children- title, url and image- but getting errors all the time- please help , what am i doing wrong? 


<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    function getContent($value)
        {
            $homepage = file_get_contents('https://www.youtube.com/results?search_query=' . $value);
            $doc = new DOMDocument();
            libxml_use_internal_errors(TRUE); //disable libxml errors
            //check if any html is actually returned
            if (!empty($homepage)) {
                //load
                $doc->loadHTML($homepage);
                //remove errors for yucky HTML
                libxml_clear_errors();
                //get DOMxPath
                $scriptXpath = new DOMXPath($doc);

                //get all the ytd-video-renderer's
                $scriptRows = $scriptXpath->query('//*[@class="item-section"]/li[position()>1]');

                //get all the ytd-channel-renderer's
                // $scriptRow = $scriptXpath->query('//ytd-channel-renderer');//dont forget channels
                $videos = array();
                foreach ($scriptRows as $scriptRow) {

                    $VideoTitle = $scriptRow->{'/div/div/div/h3/a/@title'};
                    $VideoUrl = 'https://youtube.com' .$scriptRow->{'/div/div/div[2]/h3/a/@href'};
                    $VideoImg =  $scriptRow->{'/div/div/div[1]/a/div/span/img/@src'};
                  // add to the end of a array of videos
                    $videos[] = [
                        'title' => $VideoTitle,
                        'url' => $VideoUrl,
                        'image' => $VideoImg,
                    ];


                }

            }

<!-- end snippet -->

