+
+ static function entryId($str) {
+ $dom = new DOMDocument;
+ $dom->loadXML($str);
+ $path = new DOMXPath($dom);
+ $path->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
+
+ $links = $path->query('/atom:entry/atom:id', $dom->documentRoot);
+ if ($links && $links->length) {
+ if ($links->length > 1) {
+ throw new Exception('Bad Atom entry; has multiple id entries.');
+ }
+ $link = $links->item(0);
+ $url = $link->textContent;
+ return $url;
+ } else {
+ throw new Exception('Atom entry lists no id.');
+ }
+ }
+
+ static function getEntryInFeed($str, $id)
+ {
+ $dom = new DOMDocument;
+ $dom->loadXML($str);
+ $path = new DOMXPath($dom);
+ $path->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
+
+ $query = '/atom:feed/atom:entry[atom:id="'.$id.'"]';
+ $items = $path->query($query, $dom->documentRoot);
+ if ($items && $items->length) {
+ return $items->item(0);
+ } else {
+ return null;
+ }
+ }