XML::RSS does not support XML "Extensions" ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have been having trouble parsing XML with "extensions" using
XML::RSS.  I believe (after 10 minutes of research) that the simple
explanation of an XML "extension" is: an attribute in the enclosure
with a colon in its name.  A more complicated explanation is
apparently here [1].

Here is an example snippet of XML with an "extension":

<enclosure sparkle:version="5.1.41" ... />

You see the attribute "sparkle:version" contains a colon.

Now, I can generate XML containing such an "extension" using
XML::RSS::addItem().  But when I parse such XML using
XML::RSS::parsefile(), and then access the 'enclosure' hash of its
'items' [2], I expect the key "sparkle:version" but I get simply
"version" instead. [3]  It seems that XML::RSS doesn't like the colon.

I don't see any open bugs on XML::RSS.  Is this a bug/enhancement, or
am I using it incorrectly, or is there a module that supports

I don't believe this limitation on colons in key names is in Perl,
because I can define a colon in a hash key [4] and get the expected
result [5].

Thank you,

Jerry Krinock

[1]  http://www.ibm.com/developerworks/xml/library/x-wxxm36.html

my $rss = new XML::RSS (version => '2.0') ;
$rss->parsefile($tempPath) ;
    my $itemRef = $}[$i] ;
    my $enclosure = $$itemRef ;
    while( my ($k, $v) = each %$enclosure ) {
        print "key: $k, value: $v.\n";

[3]  Console output...
key: version, value: 5.1.41.

my %hash = ();
$hash{ 'color' } = 'red';
$hash{ 'sparkle:version' } = "5.1.41";
while( my ($k, $v) = each %hash ) {
    print "key: $k, value: $v.\n";

[5]  Console output...
key: sparkle:version, value: 5.1.41.
key: color, value: red.

Re: XML::RSS does not support XML "Extensions" ?

Jerry Krinock wrote:
Quoted text here. Click to load it

Colons in names have a defined role in XML, they denote a namespace. So
sparkle:version means that a sparkle namespace should be defined somewhere in
the ancestors of the element. If there is no such definition a namespace-aware
XML processor will complain. It looks like XML::RSS doesn't complain, but
ignores the namespace prefix.

I could be a bug, but in any case you should fix your document, either by adding
the namespace declaration, or by not using colons in attribute (and element)


Site Timeline