.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "XML::RSS::LibXML 3pm"
.TH XML::RSS::LibXML 3pm "2020-12-29" "perl v5.32.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
XML::RSS::LibXML \- XML::RSS with XML::LibXML
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 3
\& use XML::RSS::LibXML;
\& my $rss = XML::RSS::LibXML\->new;
\& $rss\->parsefile($file);
\&
\& print "channel: $rss\->{channel}\->{title}\en";
\& foreach my $item (@{ $rss\->{items} }) {
\& print " item: $item\->{title} ($item\->{link})\en";
\& }
\&
\& # Add custom modules
\& $rss\->add_module(uri => $uri, prefix => $prefix);
\&
\& # See docs for XML::RSS for these
\& $rss\->channel(...);
\& $rss\->add_item(...);
\& $rss\->image(...);
\& $rss\->textinput(...);
\& $rss\->save(...);
\&
\& $rss\->as_string($format);
\&
\& # XML::RSS::LibXML only methods
\&
\& my $version = $rss\->version;
\& my $base = $rss\->base;
\& my $hash = $rss\->namespaces;
\& my $list = $rss\->items;
\& my $encoding = $rss\->encoding;
\& my $modules = $rss\->modules;
\& my $output = $rss\->output;
\& my $stylesheets = $rss\->stylesheets;
\& my $num_items = $rss\->num_items;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
XML::RSS::LibXML uses XML::LibXML (libxml2) for parsing \s-1RSS\s0 instead of \s-1XML::RSS\s0'
XML::Parser (expat), while trying to keep interface compatibility with \s-1XML::RSS.\s0
.PP
\&\s-1XML::RSS\s0 is an extremely handy tool, but it is unfortunately not exactly the
most lean or efficient \s-1RSS\s0 parser, especially in a long-running process.
So for a long time I had been using my own version of \s-1RSS\s0 parser to get the
maximum speed and efficiency \- this is the re-packaged version of that module,
such that it adheres to the \s-1XML::RSS\s0 interface.
.PP
Use this module when you have severe performance requirements working with
\&\s-1RSS\s0 files.
.SH "VERSION 0.3105"
.IX Header "VERSION 0.3105"
The original \s-1XML::RSS\s0 has been evolving in fairly rapid manner lately,
and that meant that there were a lot of features to keep up with.
To keep compatibility, I've had to pretty much rewrite the module from
ground up.
.PP
Now XML::RSS::LibXML is *almost* compatible with \s-1XML::RSS.\s0 If there are
problems, please send in bug reports (or more preferrably, patches ;)
.SH "COMPATIBILITY"
.IX Header "COMPATIBILITY"
There seems to be a bit of confusion as to how compatible XML::RSS::LibXML
is with \s-1XML::RSS:\s0 XML::RSS::LibXML is \fB\s-1NOT\s0\fR 100% compatible with \s-1XML::RSS.\s0
For instance XML::RS::LibXML does not do a complete parsing of the \s-1XML\s0 document
because of the way we deal with XPath and libxml's \s-1DOM\s0 (see \s-1CAVEATS\s0 below)
.PP
On top of that, I originally wrote XML::RSS::LibXML as sort of a fast
replacement for \s-1XML::RAI,\s0 which looked cool in terms of abstracting the
various modules. And therefore versions prior to 0.02 worked more like
\&\s-1XML::RAI\s0 rather than \s-1XML::RSS.\s0 That was a mistake in hind sight, so it has
been addressed (Since XML::RSS::LibXML version 0.08, it even supports
writing \s-1RSS :\s0)
.PP
From now on XML::RSS::LibXML will try to match \s-1XML::RSS\s0's functionality as
much as possible in terms of parsing \s-1RSS\s0 feeds. Please send in patches and
any tests that may be useful!
.SH "PARSED STRUCTURE"
.IX Header "PARSED STRUCTURE"
Once parsed the resulting data structure resembles that of \s-1XML::RSS.\s0 However,
as one addition/improvement, XML::RSS::LibXML uses a technique to allow users
to access complex data structures that \s-1XML::RSS\s0 doesn't support as of this
writing.
.PP
For example, suppose you have a tag like the following:
.PP
.Vb 6
\&
\& ...
\&
\& foo bar baz
\&
\&
.Ve
.PP
All of the fields in this construct can be accessed like so:
.PP
.Vb 3
\& $rss\->channel\->{tag} # "foo bar baz"
\& $rss\->channel\->{tag}{attr1} # "val1"
\& $rss\->channel\->{tag}{attr2} # "val2"
.Ve
.PP
See XML::RSS::LibXML::MagicElement for details.
.SH "METHODS"
.IX Header "METHODS"
.SS "new(%args)"
.IX Subsection "new(%args)"
Creates a new instance of XML::RSS::LibXML. You may specify a version or an
\&\s-1XML\s0 base in the constructor args to control which output format \fBas_string()\fR
will use.
.PP
.Vb 1
\& XML::RSS::LibXML\->new(version => \*(Aq1.0\*(Aq, base => \*(Aqhttp://example.com/\*(Aq);
.Ve
.PP
The \s-1XML\s0 base will be included only in \s-1RSS 2.0\s0 output. You can also specify the
encoding that you expect this \s-1RSS\s0 object to use when creating an \s-1RSS\s0 string
.PP
.Vb 1
\& XML::RSS::LiBXML\->new(encoding => \*(Aqeuc\-jp\*(Aq);
.Ve
.SS "parse($string)"
.IX Subsection "parse($string)"
Parse a string containing \s-1RSS.\s0
.SS "parsefile($filename)"
.IX Subsection "parsefile($filename)"
Parse an \s-1RSS\s0 file specified by \f(CW$filename\fR
.SS "channel(%args)"
.IX Subsection "channel(%args)"
.SS "add_item(%args)"
.IX Subsection "add_item(%args)"
.SS "image(%args)"
.IX Subsection "image(%args)"
.SS "textinput(%args)"
.IX Subsection "textinput(%args)"
These methods are used to generate \s-1RSS.\s0 See the documentation for \s-1XML::RSS\s0
for details. Currently \s-1RSS\s0 version 0.9, 1.0, and 2.0 are supported.
.PP
Additionally, add_item takes an extra parameter, \*(L"mode\*(R", which allows
you to add items either in front of the list or at the end of the list:
.PP
.Vb 5
\& $rss\->add_item(
\& mode => "append",
\& title => "...",
\& link => "...",
\& );
\&
\& $rss\->add_item(
\& mode => "insert",
\& title => "...",
\& link => "...",
\& );
.Ve
.PP
By default, items are appended to the end of the list
.SS "as_string($format)"
.IX Subsection "as_string($format)"
Return the string representation of the parsed \s-1RSS.\s0 If \f(CW$format\fR is true, this
flag is passed to the underlying XML::LibXML object's \fBtoString()\fR method.
.PP
By default, \f(CW$format\fR is true.
.ie n .SS "add_module(uri => $uri, prefix => $prefix)"
.el .SS "add_module(uri => \f(CW$uri\fP, prefix => \f(CW$prefix\fP)"
.IX Subsection "add_module(uri => $uri, prefix => $prefix)"
Adds a new module. You should do this before parsing the \s-1RSS.\s0
XML::RSS::LibXML understands a few modules by default:
.PP
.Vb 7
\& rdf => "http://www.w3.org/1999/02/22\-rdf\-syntax\-ns#",
\& dc => "http://purl.org/dc/elements/1.1/",
\& syn => "http://purl.org/rss/1.0/modules/syndication/",
\& admin => "http://webns.net/mvcb/",
\& content => "http://purl.org/rss/1.0/modules/content/",
\& cc => "http://web.resource.org/cc/",
\& taxo => "http://purl.org/rss/1.0/modules/taxonomy/",
.Ve
.PP
So you do not need to add these explicitly.
.SS "save($file)"
.IX Subsection "save($file)"
Saves the \s-1RSS\s0 to a file
.SS "\fBitems()\fP"
.IX Subsection "items()"
Syntactic sugar to allow statement like this:
.PP
.Vb 3
\& foreach my $item ($rss\->items) {
\& ...
\& }
.Ve
.PP
Instead of
.PP
.Vb 3
\& foreach my $item (@{$rss\->{items}}) {
\& ...
\& }
.Ve
.PP
In scalar context, returns the reference to the list of items.
.SS "\fBcreate_libxml()\fP"
.IX Subsection "create_libxml()"
Creates, configures, and returns an XML::LibXML object. Used by \f(CW\*(C`parse()\*(C'\fR to
instantiate the parser used to parse the feed.
.SH "PERFORMANCE"
.IX Header "PERFORMANCE"
Here's a simple benchmark using benchmark.pl in this distribution,
using \s-1XML::RSS 1.29_02\s0 and XML::RSS::LibXML 0.30
.PP
.Vb 6
\& daisuke@beefcake XML\-RSS\-LibXML$ perl \-Mblib tools/benchmark.pl t/data/rss20.xml
\& XML::RSS \-> 1.29_02
\& XML::RSS::LibXML \-> 0.30
\& Rate rss rss_libxml
\& rss 25.6/s \-\- \-67%
\& rss_libxml 78.1/s 205% \-\-
.Ve
.SH "CAVEATS"
.IX Header "CAVEATS"
\&\- Only first level data under and - tags are
examined. So if you have complex data, this module will not pick it up.
For most of the cases, this will suffice, though.
.PP
\&\- Namespace for namespaced attributes aren't properly parsed as part of
the structure. Hopefully your \s-1RSS\s0 doesn't do something like this:
.PP
.Vb 1
\&
.Ve
.PP
You won't be able to get at \*(L"bar\*(R" in this case:
.PP
.Vb 2
\& $xml\->{foo}{baz}; # "whee"
\& $xml\->{foo}{bar}{baz}; # nope
.Ve
.PP
\&\- Some of the structures will need to be handled via
XML::RSS::LibXML::MagicElement. For example, \s-1XML::RSS\s0's \s-1SYNOPSIS\s0 shows
a snippet like this:
.PP
.Vb 8
\& $rss\->add_item(title => "GTKeyboard 0.85",
\& # creates a guid field with permaLink=true
\& permaLink => "http://freshmeat.net/news/1999/06/21/930003829.html",
\& # alternately creates a guid field with permaLink=false
\& # guid => "gtkeyboard\-0.85
\& enclosure => { url=> \*(Aqhttp://example.com/torrent\*(Aq, type=>"application/x\-bittorrent" },
\& description => \*(Aqblah blah\*(Aq
\& );
.Ve
.PP
However, the enclosure element will need to be an object:
.PP
.Vb 6
\& enclosure => XML::RSS::LibXML::MagicElement\->new(
\& attributes => {
\& url => \*(Aqhttp://example.com/torrent\*(Aq,
\& type=>"application/x\-bittorrent"
\& },
\& );
.Ve
.PP
\&\- Some elements such as permaLink elements are not really parsed
such that it can be serialized and parsed back and force. I could fix
this, but that would break some compatibility with \s-1XML::RSS\s0
.SH "TODO"
.IX Header "TODO"
Tests. Currently tests are simply stolen from \s-1XML::RSS.\s0 It would be nice
to have tests that do more extensive testing for correctness
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\s-1XML::RSS\s0, XML::LibXML, XML::LibXML::XPathContext
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
Copyright (c) 2005\-2007 Daisuke Maki , Tatsuhiko Miyagawa . All rights reserved.
.PP
Many tests were shamelessly borrowed from \s-1XML::RSS 1.29_02\s0
.PP
Development partially funded by Brazil, Ltd.
.PP
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.