我有返回一些 xml 数据的 Web 服务的 URL。我需要加载此 xml 数据并仅包含我网站上的日期标记的值。如何才能做到这一点?
这是返回 xml 的 url:
<?xml version="1.0"?>
<prayer>
<fajr>4:12</fajr>
<sunrise>5:43</sunrise>
<dhuhr>1:03</dhuhr>
<asr>5:00</asr>
<maghrib>8:22</maghrib>
<isha>9:54</isha>
<date>July 21, 2012</date>
<hijri>2 Ramadan 1433</hijri>
<city>New York</city>
<country>Usa</country>
<website>www.IslamicFinder.org</website>
</prayer>
最佳答案
尝试使用 PHP 的 SimpleXMLElement
<?php
$url = 'http://www.islamicfinder.org/prayer_service.php?country=usa&city=new_york&state=NY&zipcode=10006&latitude=40.7092&longitude=-74.0128&timezone=-5&HanfiShafi=1&pmethod=5&fajrTwilight1=10&fajrTwilight2=10&ishaTwilight=10&ishaInterval=30&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml';
$result = new SimpleXMLElement($url, NULL, true);
echo $result->date;
?>
NULL 意味着我们没有传递任何选项。 True 表示我们正在从 URL 获取数据。查看参数 here .
关于javascript - 如何将xml字段调用到html中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11595931/