首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SimpleXMLElement遍历XML内部节点

使用SimpleXMLElement遍历XML内部节点
EN

Stack Overflow用户
提问于 2014-06-02 17:37:22
回答 1查看 36关注 0票数 0

下面是我的XML

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
-<RentListings>
    -<RentListing>
        <Country>UAE</Country>
        <State>Dubai</State>
        <City>Dubai</City>
        <District>Dubailand District</District>
        <Comm>Arabian Ranches</Comm>
        <SubComm>Al Mahra</SubComm>
        <Bedroom>2</Bedroom>
        -<Images>
            <ImageUrl>http://cdn.example.com/img/1.jpg</ImageUrl>
            <ImageUrl>http://cdn.example.com/img/2.jpg</ImageUrl>
            <ImageUrl>http://cdn.example.com/img/3.jpg</ImageUrl>
        </Images>
        <Last_Updated>Jun 1 2014 9:46AM</Last_Updated>
        <Unit_Status>Vacant</Unit_Status>
    </RentListing>
</RentListings>

下面是我从XML中提取细节的代码

代码语言:javascript
复制
$XMLrent = new SimpleXMLElement($xml_here);
foreach($XMLrent->RentListing AS $oEntry){
    echo $oEntry->City;
    **[Images should be place here]**
}

我的问题是我不知道如何检索和遍历<Images>节点

EN

回答 1

Stack Overflow用户

发布于 2014-06-02 17:46:23

代码语言:javascript
复制
 foreach($oEntry->Images->ImageUrl AS $oImageUrl){
     echo $oImageUrl;
 }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23991468

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档