Php 我想在我的XML搜索结果上显示一个图像,每个页面都有URL链接

Php 我想在我的XML搜索结果上显示一个图像,每个页面都有URL链接,php,xml,Php,Xml,这是我的xml文件: <pages> <link> <image>I want small face image here</image> <title>Address Here | Name Here</title> <url>https://webpage.here</url>

这是我的xml文件:

            <pages>
            <link>
            <image>I want small face image here</image>
            <title>Address Here | Name Here</title>
            <url>https://webpage.here</url>
            </link>
            <link>
            <image>I want small face image here</image>
            <title>Address Here | Name Here</title>
            <url>https://webpage.here</url>
            </link>
            </pages>

我想要一张小脸的照片
地址在这里|名字在这里
https://webpage.here
我想要一张小脸的照片
地址在这里|名字在这里
https://webpage.here
以下是我的php代码:

            <?php
            $xmlDoc=new DOMDocument();
            $xmlDoc->load("links.xml");

            $x=$xmlDoc->getElementsByTagName('link');

            //get the q parameter from URL
            $q=$_GET["q"];

            //lookup all links from the xml file if length of q>0
            if (strlen($q)>1) {
              $hint="";
              for($i=0; $i<($x->length); $i++) {
                $y=$x->item($i)->getElementsByTagName('title');
                $z=$x->item($i)->getElementsByTagName('url');
                if ($y->item(0)->nodeType==1) {
                  //find a link matching the search text
                  if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) {
                    if ($hint=="") {
                      $hint="<br /><a href='" .
                      $z->item(0)->childNodes->item(0)->nodeValue .
                      "' target='_self'>" .
                      $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
                    } else {
                      $hint=$hint . "<br /><br /><a href='" .
                      $z->item(0)->childNodes->item(0)->nodeValue .
                      "' target='_self'>" .
                      $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
                    }
                  }
                }
              }
            }

            // Set output to "no suggestion" if no hint was found
            // or to the correct values
            if ($hint=="") {
              $response="<br />no suggestion";
            } else {
              $response=$hint;
            }

            //output the response
            echo $response;
            ?>

我希望在搜索时显示的结果:

小拇指图像 链接到他/她的页面的地址/名称

我对编码很陌生。我真的很感谢你的帮助

多谢各位


我知道我的帖子主要是代码;请考虑一个寻求解决问题的新手。p> 如果在条件中对解析后的xml信息进行var_dump()以检查是否已请求提示,您会得到任何结果吗?