链接两个xml文件并从另一个的对象访问一个 [英] link two xml files and access one from object of the other

查看:105
本文介绍了链接两个xml文件并从另一个的对象访问一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have two xml documents named pages.xml and images.xml. here are they:

<Pages>   
    <home category = "start"> 
    <title>something</title>
    <link>something</link>
    <description>Welcome to my official home page</description>  
    <content>bla bla bla</content> 
    <images ID = "ANOTHER">
      i want these images to be fetched from images.xml 
    </images> 
    </home >

    <about category = "start">   
    <images ID = "ANOTHER">
     i want these images to be fetched from images.xml 
    </images>  
    </about>  
</Pages>

And the images.xml:

<images category = "start", ID = "ANOTHER">
    <IMG1 attribute = "name">path to this Image </IMG1>
    <IMG2 attribute = "name">path to this Image </IMG2>
    <IMG3 attribute = "name">path to this Image </IMG3>
    <IMG4 attribute = "name">path to this Image </IMG4>
</images>

My question is, is it possible to link both files from pages.xml, 
such that if i do this: 

//xpath select all tags under Pages/home/images 
$xml = funLoadxml("pages.xml");
$result = $xml->xpath("Pages/home/images[@start]/*")       //dont know if this is correct anyway

i will get the result of images in images.xml, which are not actually
present in pages.xml. in other words, can i link images.xml and pages.xml
and access images.xml from a single xpath query on pages.xml object ?
if so, please guide me. any help will be so much appreciated

推荐答案

xml = funLoadxml( pages.xml);
xml = funLoadxml("pages.xml");


result =
result =


xml-> xpath( Pages / home / images [@start] / * // 不知道这是否正确
xml->xpath("Pages/home/images[@start]/*") //dont know if this is correct anyway

i will get the result of images in images.xml, which are not actually
present in pages.xml. in other words, can i link images.xml and pages.xml
and access images.xml from a single xpath query on pages.xml object ?
if so, please guide me. any help will be so much appreciated


这篇关于链接两个xml文件并从另一个的对象访问一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆