从xml解析器获取数据[重复]

时间:2022-12-04 15:38:46

Possible Duplicate:
Best XML Parser for PHP

可能重复:PHP的最佳XML解析器

I would like to display the array I get from this url in a table in my website. However I have no clue where to begin. The link is

我想在我网站的表格中显示我从这个网址获得的数组。但是我不知道从哪里开始。链接是

http://www.islamicfinder.org/prayer_service.php?country=usa&city=germantown&state=MD&zipcode=20876&latitude=39.2074&longitude=-77.2311&timezone=-5&HanfiShafi=1&pmethod=5&fajrTwilight1=10&fajrTwilight2=10&ishaTwilight=10&ishaInterval=30&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml

Thanks for any help.

谢谢你的帮助。

1 个解决方案

#1


0  

Why don't you try this simple HTML parser?

你为什么不尝试这个简单的HTML解析器?

$data = Array();
$html = file_get_html('http://www.islamicfinder.org/prayer_service.php?country=usa&city=germantown&state=MD&zipcode=20876&latitude=39.2074&longitude=-77.2311&timezone=-5&HanfiShafi=1&pmethod=5&fajrTwilight1=10&fajrTwilight2=10&ishaTwilight=10&ishaInterval=30&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml');

foreach($html->find('prayer') as $prayer)
{
    $data['fayr']    = $prayer->find('fayr', 0)->plaintext;
    $data['sunrise'] = $prayer->find('sunrise', 0)->plaintext;
    $data['dhur']    = $prayer->find('dhur', 0)->plaintext;
}

#1


0  

Why don't you try this simple HTML parser?

你为什么不尝试这个简单的HTML解析器?

$data = Array();
$html = file_get_html('http://www.islamicfinder.org/prayer_service.php?country=usa&city=germantown&state=MD&zipcode=20876&latitude=39.2074&longitude=-77.2311&timezone=-5&HanfiShafi=1&pmethod=5&fajrTwilight1=10&fajrTwilight2=10&ishaTwilight=10&ishaInterval=30&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml');

foreach($html->find('prayer') as $prayer)
{
    $data['fayr']    = $prayer->find('fayr', 0)->plaintext;
    $data['sunrise'] = $prayer->find('sunrise', 0)->plaintext;
    $data['dhur']    = $prayer->find('dhur', 0)->plaintext;
}