/** * Creates a feed object with specified XML string. * * @param string $xmlString An XML string representing the feed object. * * @return none */ public function parseXml($xmlString) { $feedXml = simplexml_load_string($xmlString); $attributes = $feedXml->attributes(); $feedArray = (array) $feedXml; if (!empty($attributes)) { $this->attributes = (array) $attributes; } if (array_key_exists('author', $feedArray)) { $this->author = $this->processAuthorNode($feedArray); } if (array_key_exists('entry', $feedArray)) { $this->entry = $this->processEntryNode($feedArray); } if (array_key_exists('category', $feedArray)) { $this->category = $this->processCategoryNode($feedArray); } if (array_key_exists('contributor', $feedArray)) { $this->contributor = $this->processContributorNode($feedArray); } if (array_key_exists('generator', $feedArray)) { $generator = new Generator(); $generatorValue = $feedArray['generator']; if (is_string($generatorValue)) { $generator->setText($generatorValue); } else { $generator->parseXml($generatorValue->asXML()); } $this->generator = $generator; } if (array_key_exists('icon', $feedArray)) { $this->icon = (string) $feedArray['icon']; } if (array_key_exists('id', $feedArray)) { $this->id = (string) $feedArray['id']; } if (array_key_exists('link', $feedArray)) { $this->link = $this->processLinkNode($feedArray); } if (array_key_exists('logo', $feedArray)) { $this->logo = (string) $feedArray['logo']; } if (array_key_exists('rights', $feedArray)) { $this->rights = (string) $feedArray['rights']; } if (array_key_exists('subtitle', $feedArray)) { $this->subtitle = (string) $feedArray['subtitle']; } if (array_key_exists('title', $feedArray)) { $this->title = (string) $feedArray['title']; } if (array_key_exists('updated', $feedArray)) { $this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $feedArray['updated']); } }