我從公開的Google日曆獲取XML源。看起來是這樣的:解析Google日曆XML Feed
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='................' xmlns:gd='http://schemas.google.com/g/2005'>
<id>http://www.google.com/calendar/feeds/........./public/full</id>
<updated>2009-08-24T10:57:00.000Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'/>
<title type='text'>Sports Events</title>
.....
<entry>
<id>...........</id>
<published>2009-08-14T00:29:58.000Z</published>
<updated>2009-08-14T00:29:58.000Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'/>
..............
<georss:where>
<gml:Point>
<gml:pos>11.111111 -22.22222</gml:pos>
</gml:Point>
</georss:where>
<gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'/>
<gd:transparency value='http://schemas.google.com/g/2005#event.transparent'/>
<gCal:uid value='[email protected]'/>
<gCal:sequence value='0'/>
<gd:when startTime='2009-10-03' endTime='2009-10-04'/>
.............
我們PHP:
$calendar = simplexml_load_file('http://my.feed.com');
foreach ($calendar->entry as $item) {
//here I get the whole <entry> node
$gd = $item->children('http://schemas.google.com/g/2005');
// now in $gd I have all nodes like <gd:XXXXX>
}
的問題是如何從這裏獲得價值?
<gml:pos>11.111111 -22.22222</gml:pos>
它沒有出現在我的$ gd變量中,如何獲得這個節點?
哦,這太棒了。謝謝你給我看這個圖書館:) – 6bytes 2009-08-28 15:52:04
哈哈我的榮幸!這很好,不是嗎? – 2009-08-28 21:45:22
這是非常令人印象深刻的 – 2009-12-19 15:18:49