0

当我从 xml 文件中读取图像时,如何在链接中显示它?例如使用此代码:

img.php

 $what = 'ResourceLink';

$reader = new XMLReader();
$reader->open('http://www.file.xml/getRecordsX.do?user=user01&password=password01&identifier=978841580114-6&metadataformat=ONIX&version=3.0');
while ($reader->read()) {
    if ($reader->nodeType == XMLReader::ELEMENT) {
        $exp = $reader->expand();
        if ($exp->nodeName == $what)
            echo '<img src="' . $exp->nodeValue .' " height="15%" width="15%" />';
    }
}

链接.php

<img class="foto" src="img.php?id=9788477828921" width="70" title="TIERRA VISTA DESDE EL CIELO, LA" alt="TIERRA VISTA DESDE EL CIELO, LA" border="0">';

我想传递 id,发送它并在没有 ajax 的链接中显示图像。

是一个愚蠢的错误。我在使用代码之前发送了标题。这运行良好。谢谢和道歉

$id = $_GET['id'];
$what = 'ResourceLink';
$reader = new XMLReader();
$reader->open('http://file.xml/getRecordsX.do?user=user01&password=pass01&identifier='.$id.'&metadataformat=ONIX&version=3.0');
while ($reader->read()) {
    if ($reader->nodeType == XMLReader::ELEMENT) {
        $exp = $reader->expand();
        if ($exp->nodeName == $what)
           $img = $exp->nodeValue;
    }}
header('Content-Type: image/jpg');
readfile($img);
4

0 回答 0