开发者

XML file stores image location then use SimpleXML

开发者 https://www.devze.com 2023-03-28 16:34 出处:网络
I just want to know if i\'m doing this right. I put a markup for the i开发者_如何学Pythonmage location in my xml file. I read it using this statement for php.

I just want to know if i'm doing this right. I put a markup for the i开发者_如何学Pythonmage location in my xml file. I read it using this statement for php.

foreach($xml->children() as $image)
{
echo "<img src=\"$image->image\"/>";
}

Is this fine?


if your xml file is like this

<?xml version="1.0" encoding="ISO-8859-1"?>

    <image>a.jpg</image>
    <image>b.jpg </image>
    <image>c.jpg </image>
    <image>d.jpg </image>

you can use this code

<?php
$xml = simplexml_load_file("test.xml");



foreach($image->children() as $image)
{
    echo "<img src=\"$image->image\"/>";
}

?> 
0

精彩评论

暂无评论...
验证码 换一张
取 消