= xml_parse( $this->parser, $source );
if (! $status ) {
$errorcode = xml_get_error_code( $this->parser );
if ( $errorcode != XML_ERROR_NONE ) {
$xml_error = xml_error_string( $errorcode );
$error_line = xml_get_current_line_number($this->parser);
$error_col = xml_get_current_column_number($this->parser);
$errormsg = "$xml_error at line $error_line, column $error_col";
$this->error( $errormsg );
}
}
xml_parser_free( $this->parser );
}
function feed_start_element($p, $element, &$attrs) {
$el = $element = strtolower($element);
$attrs = array_change_key_case($attrs, CASE_LOWER);
// check for a namespace, and split if found
$ns = false;
if ( strpos( $element, ':' ) ) {
list($ns, $el) = split( ':', $element, 2);
}
if ( $ns and $ns != 'rdf' ) {
$this->current_namespace = $ns;
}
# if feed type isn't set, then this is first element of feed
# identify feed from root element
#
if (!isset($this->feed_type) ) {
if ( $el == 'rdf' ) {
$this->feed_type = RSS;
$this->feed_version = '1.0';
}
elseif ( $el == 'rss' ) {
$this->feed_type = RSS;
$this->feed_version = $attrs['version'];
}
elseif ( $el == 'feed' ) {
$this->feed_type = ATOM;
$this->feed_version = $attrs['version'];
$this->inchannel = true;
}
return;
}
if ( $el == 'channel' )
{
$this->inchannel = true;
}
elseif ($el == 'item' or $el == 'entry' )
{
$this->initem = true;
}
// if we're in the default namespace of an RSS feed record textinput or image fields
elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
{
$this->intextinput = true;
}
elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
{
$this->inimage = true;
}
elseif ($this->feed_type == ATOM and $el == 'content')
{
$this->incontent = true;
}
// if in an Atom <content> field treat tags as text
elseif ($this->feed_type == ATOM and $this->incontent and $this->initem)
{
$attrs_str = join(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs) ) );
$this->append( $this->current_item['atom_content'], "<$element $attrs_str>" );
array_unshift($this->stack, $el);
}
// if we're parsing an ATOM feed, treat <link rel="alternate"> as the default link
elseif ($this->feed_type == ATOM and $el == 'link' )
{
if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
{
$link_el = 'link';
}
else {
$link_el = 'link_' . $attrs['rel'];
}
if ( $this->initem ) {
if ( $this->current_namespace ) {
$this->current_item[ $this->current_namespace ][$link_el] = $attrs['href'];
}
else {
$this->current_item[$link_el] = $attrs['href'];
}
}
elseif ( $this->inchannel ) {
if ( $this->current_namespace ) {
$this->channel[ $this->current_namespace ][ $link_el ] = $attrs['href'];
}
else {
$this->channel[$link_el] = $attrs['href'];
}
}
}
// set stack[0] to current element
else {
array_unshift($this->stack, $el);
}
}
function feed_cdata ($p, $text) {
if ($this->feed_type == ATOM and $this->incontent and $this->initem)
{
$this->append( $this->current_item['atom_content'], $text );
}
else
if ( $this->initem )
{
$current_el = join('_', array_reverse($this->stack));
if ( $this->