Re: Questions about XML:LibXML
- From: xhoster@xxxxxxxxx
- Date: 17 Dec 2007 00:09:18 GMT
fergus@xxxxxxxxxxxxxxxx (Fergus McMenemie) wrote:
I am currently migrating several large scripts from XML::DOM to
XML::LIBXML and the transistion has hightligted a number of problems.
Out of my own curiosity, what is the driving force behind the change?
Both modules have rather poorly documented aspects and the move to
XML::LIBXML is proving painful.
A typical use of either module to read XML goes along the lines of
my $parser =XML::LibXML->new();
my $tree = $parser->parse_file($metafile);
XML::LIBXML seems to require an extra step of
my $pubmeta = $tree->getDocumentElement();
I think my misunderstandings starts at the very first line.
- What this $parser object do?
It lets you set the default options to the parser. If you never do
that (and the docs don't even explain how you would go about doing it)
then it is pretty useless. Consider just another part of the bloat and rot
that seems to follow XML where ever it goes.
If I am parsing multiple files
do I need a seperate parser instance for each file?
No. But I would use one anyway. Creation of a XML::LibXML parser
is extremely light weight (unlike XML::DOM).
- Having used parse_file() within a subroutine do I need to
keep it around or is it just $tree that needs kept?
- Or can I get away with just keeping $pubmeta in scope?
You can do even better, not even explicitly having the intermediaries:
my $pubmeta =
XML::LibXML->new()->parse_file($metafile)->getDocumentElement();
In answering or commenting on the above bear in mind that I am
opening lots of XML files, merging elements from them into a master.
Using the same parser over and over in XML::LibXML might save you around
one second for every few hundred thousand files or so. Not worth worrying
about in my book.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.
- Follow-Ups:
- Re: Questions about XML:LibXML
- From: Fergus McMenemie
- Re: Questions about XML:LibXML
- References:
- Questions about XML:LibXML
- From: Fergus McMenemie
- Questions about XML:LibXML
- Prev by Date: Questions about XML:LibXML
- Next by Date: Win32::Process::Create(vxsim) cmd line argument trouble
- Previous by thread: Questions about XML:LibXML
- Next by thread: Re: Questions about XML:LibXML
- Index(es):
Relevant Pages
|
|