Subject: | Problem accessing source from a feed entry |
Date: | Tue, 28 Aug 2007 12:54:24 +0200 |
To: | bug-XML-Atom [...] rt.cpan.org |
From: | Kjell-Magne Øierud <kjellm [...] linpro.no> |
I am having a problem with accessing the source attribute from a feed
entry. My problem is easiest described by the following annotated
code example:
------------------------------------------------------------------------------
use warnings;
use strict;
use Data::Dumper;
use XML::Atom::Feed;
# Creating a feed with one entry
my $f = XML::Atom::Feed->new();
my $e = XML::Atom::Entry->new();
$e->title("foo");
# Add a source to the entry
my $es = XML::Atom::Entry->new;
$es->title("bar");
$es->id("2");
$e->source($es);
$f->add_entry($e);
# Show that the source of the entry is correct when generating the XML.
warn $f->as_xml();
my @x = $f->entries;
eval {
# Try to access source in the anticipated way.
warn $x[0]->source->title;
};
if ($@) {
warn $@;
# Prints "Can't locate object method "title" via package "bar2"
# (perhaps you forgot to load "bar2"?)"
}
# Dumper shows that the source is a string?!
warn Dumper($x[0]->source);
# But the generated XML is correct, so the data must be accessible some way
# or another:
warn $x[0]->elem->getElementsByTagName("source")->get_node(0)
->getElementsByTagName('title')->string_value;
------------------------------------------------------------------------------
To me this looks like a bug, but I can have misunderstood
something ... If so, please enlighten me :)
My system:
* This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
* XML::Atom 0.25
* Linux 2.6.20, Ubuntu 7.04
Regards,
Kjell-Magne Øierud