static function import(SimpleXMLElement $el) { $fd = new AtomFeedData(); if (isset($el->link)) { $fd->link = (string) $el->link['href']; } foreach ($el->children() as $v) { if ($v->getName() == 'entry') { $fe = new FeedEntry((string) $v->title, (string) $v->link['href'], (string) $v->content); foreach ($v->children() as $e) { if ($e->getName() == "updated") { $fe->last_update = (string) $e; } elseif ($e->getName() == "category") { $fe->addCategory((string) $e['term'], (string) $e['scheme']); } elseif ($e->getName() == "source") { $fe->setSource((string) $e['title'], (string) $e['url']); } elseif ($e->getName() == "link") { $fe->addEnclosure($e['href'], $e['type'], $e['length']); } elseif ($e->getName() == "id") { $fe->guid = (string) $e; } elseif ($e->getName() == "author") { $fe->author = (string) $e->name; } elseif ($e->getName() == "link") { $fe->line = (string) $el['href']; } elseif ($e->getName() == "summary") { $fe->description = (string) $e; } elseif (!in_array($e->getName(), array("published"))) { $fe->{$e->getName()} = (string) $e; } } if (!$fe->isReady()) { throw new FeedException('Not all required fields are filled-in'); } $fd->addEntry($fe); unset($fe); } else { $fd->{(string) $v->getName()} = (string) $v; } } if (!$fd->isReady()) { throw new Exception('Not all required feilds of FeedData are filled-in'); } return $fd; }
static function import(SimpleXMLElement $el) { $fd = new RSSFeedData(); if (isset($el->image) && isset($el->image->url)) { $fd->image = (string) $el->image->url; } if (isset($el->cloud)) { $fd->cloud = array('domain' => (string) $el->cloud['domain'], 'port' => $el->cloud['port'], 'path' => $el->cloud['path'], 'procedure' => $el->cloud['registerProcedure'], 'protocol' => $el->cloud['protocol']); } if (isset($el->textInput)) { $fd->setTextInput($el->textInput->title, $el->textInput->description, $el->textInput->name, $el->textInput->link); } if (isset($el->skipHours)) { foreach ($el->skipHours->children() as $v) { if ($v->getName() == "hour") { $fd->addSkipHours((string) $v); } } } if (isset($el->skipDays)) { foreach ($el->skipDays->children() as $v) { if ($v->getName() == "day") { $df->addSkipDays((string) $v); } } } foreach ($el->children() as $v) { if ($v->getName() == 'item') { if (isset($v->description)) { $_content = (string) $v->description; } else { $_c = $v->children('content', true); $_content = (string) $_c->encoded; unset($_c); } $fe = new FeedEntry((string) $v->title, (string) $v->link, $_content); unset($_content); foreach ($v->children() as $e) { if ($e->getName() == "pubDate") { $fe->last_update = (string) $e; } elseif ($e->getName() == "category") { $fe->addCategory((string) $e, $e['domain']); } elseif ($e->getName() == "source") { $fe->setSource((string) $e, $e['url']); } elseif ($e->getName() == "enclosure") { $fe->addEnclosure($e['url'], $e['type'], $e['length']); } else { $fe->{$e->getName()} = (string) $e; } } if (!$fe->isReady()) { throw new FeedException('Not all required fields are filled-in'); } $fd->addEntry($fe); unset($fe); } elseif (in_array($v->getName(), array('image', 'cloud', 'textInput', 'skipHours', 'skipDays'))) { continue; } else { $fd->{(string) $v->getName()} = (string) $v; } } if (!$fd->isReady()) { throw new Exception('Not all required feilds of FeedData are filled-in'); } return $fd; }