0
嘿,我所有的這種類型的XML我試圖從中獲取數據。這僅僅是一個大的XML代碼剪斷:PHP xml數組解析數據
<entry>
<id>http://www.google.com/calendar/feeds/[Letters/numbers here]group.calendar.google.com/public/basic/[Letters/numbers here]</id>
<published>2013-08-01T13:40:24.000Z</published>
<updated>2013-08-01T13:40:24.000Z</updated>
<title type='html'>[Title Here]</title>
<summary type='html'>When: Tue Sep 24, 2013 7am</summary>
<content type='html'>When: Tue Sep 24, 2013 7am
<br />Event Status: confirmed
</content>
<link rel='alternate' type='text/html' href='https://www.google.com/calendar/event?eid=[Letters/numbers here]' title='alternate'/>
<link rel='self' type='application/atom+xml' href='https://www.google.com/calendar/feeds/[Letters/numbers here]group.calendar.google.com/public/basic/[Letters/numbers here]'/>
<author>
<name>[email here]</name>
<email>[email here]</email>
</author>
</entry>
etc... etc....
目前我能得到這兩個發表和更新只是做以下罰款:
<?php
$url = strtolower($_GET['url']);
$doc = new DOMDocument();
$doc->load('http://www.google.com/calendar/feeds/[number/letters here].calendar.google.com/public/basic');
$entries = $doc->getElementsByTagName("entry");
foreach ($entries as $entry) {
$tmpPublished = $entry->getElementsByTagName("published");
$published = $tmpPublished->item(0)->nodeValue;
$tmpUpdated = $entry->getElementsByTagName("updated");
$updated = $tmpUpdated->item(0)->nodeValue;
}
?>
但是我不能確定爲如何從父數組中獲取內部數據 - 在這種情況下是鏈接。
,所以我需要得到
鏈路>的href
我可以想象這將是:
$tmpLink = $entry->getElementsByTagName("link");
$link = $tmpLink->item(2)->nodeValue;
任何幫助將是巨大的!
你有沒有想過使用xpath? [相關SO問題和答案](http://stackoverflow.com/questions/1288940/domdocument-xpath-html-tag-of-each-node) – miah