douwo5710 2012-03-30 21:56
浏览 21

使用DomXML从XML访问元素/属性

I'm forced to use a server running PHP 4 and the XML service that's on the server is DomXML. My question is how do I access specific elements and attributes of the following XML document using DomXML? I tried the following with no results returned. Any help is appreciated...

if (!$xml = domxml_open_file($pathToXMLdoc)) {
//the above requires absolube path
exit("Could not access the XML source.");
}

$root = $xml->document_element();

echo($root->current_conditions->conditions['data'] . "<br>");

//XML FILE BELOW

<xml_api_reply version="1">

<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">

<forecast_information>
   <city data="Carlsbad, CA"/>
   <postal_code data="92009"/>
   <latitude_e6 data=""/>
   <longitude_e6 data=""/>
   <forecast_date data="2012-03-29"/>
   <current_date_time data="2012-03-29 11:52:00 +0000"/>
   <unit_system data="US"/>
</forecast_information>

<current_conditions>
   <condition data="Partly Cloudy"/>
   <temp_f data="62"/>
   <temp_c data="17"/>
   <humidity data="Humidity: 65%"/>
   <icon data="/ig/images/weather/partly_cloudy.gif"/>
   <wind_condition data="Wind: SW at 4 mph"/>
</current_conditions>


</weather>

</xml_api_reply>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?