public function toXml() { $keywords = ''; if (!$this->_keywords || !is_array($this->_keywords)) { $this->_keywords = array('NONE'); } foreach ($this->_keywords as $x) { $keywords .= "<keywords><![CDATA[{$x}]]></keywords>\n"; } $pics = ''; if ($this->_pictures && is_array($this->_pictures)) { foreach ($this->_pictures as $x) { if (strncasecmp('http://', $x, 7) !== 0) { continue; } $x = BaidusubmitSitemap::encodeUrl($x); $pics .= "<articlePicture><![CDATA[{$x}]]></articlePicture>\n"; } } $comment = ''; foreach ($this->_commentList as $x) { $comment .= $x->toXml(); } $video = ''; foreach ($this->_videoList as $x) { $video .= $x->toXml(); } $audio = ''; foreach ($this->_audioList as $x) { $audio .= $x->toXml(); } return "<url>\n" . "<loc><![CDATA[{$this->_url}]]></loc>\n" . "<lastmod>{$this->_lastmod}</lastmod>\n" . "<data>\n" . "<blogposting>\n" . "<headline><![CDATA[{$this->_title}]]></headline>\n" . "<url><![CDATA[{$this->_url}]]></url>\n" . "<articleAuthor>\n" . "<articleAuthor>\n" . "<alias><![CDATA[{$this->_author}]]></alias>\n" . "</articleAuthor>\n" . "</articleAuthor>\n" . "<articleBody><![CDATA[{$this->_content}]]></articleBody>\n" . "<articleTime>{$this->_publishTime}</articleTime>\n" . "<articleModifiedTime>{$this->_lastmod}</articleModifiedTime>\n" . "{$keywords}" . "<articleSection><![CDATA[{$this->_term}]]></articleSection>\n" . "{$pics}\n" . "{$video}" . "{$audio}" . "{$comment}" . "<articleCommentCount>{$this->_commentCount}</articleCommentCount>\n" . "<articleLatestComment>{$this->_latestCommentTime}</articleLatestComment>\n" . "</blogposting>\n" . "</data>\n" . "</url>\n"; }