- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Parsing XML with Perl - Which module
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 05:51 PM
тАО08-07-2005 05:51 PM
I have some fairly uncomplicated XML I wish to extract from fields from.
If I can possibly avoid doing so I would like to avoid having to install extra modules on the clients server.
Surfing the CPan modules XML::Parser showed promise but this line:
use XML::Parser;
produces this error:
_____________
Can't locate XML/Parser.pm in @INC (@INC contains: /opt/aue/bin /opt/aue/lib /opt/perl5/lib/5.00503/PA-RISC2.0 /opt/perl5/lib/5.00503 /opt/perl5/lib/site_perl/5.005/PA-
RISC2.0 /opt/perl5/lib/site_perl/5.005 .) at ./t.pl line 12.
BEGIN failed--compilation aborted at ./t.pl line 12.
_____________
However this module is installed in some places:
__________
-r--r--r-- 1 bin bin 29402 Jun 21 2001 /opt/perl/lib/site_perl/5.6.1/PA-RISC1.1-thread-multi/XML/Parser.pm
-r--r--r-- 1 bin bin 23398 Jun 21 2001 /opt/perl/lib/site_perl/5.6.1/XML/XPath/Parser.pm
-r-xr-xr-x 1 bin bin 29402 Nov 8 2000 /opt/perl5.005_03/lib/5.00503/PA-RISC1.1/XML/Parser.pm
__________
My Question: Given that this module is installed is there are good reason why it is not installed for PA-RISC2.0? Is there some other module I should be using instead?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 05:58 PM
тАО08-07-2005 05:58 PM
Re: Parsing XML with Perl - Which module
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 06:15 PM
тАО08-07-2005 06:15 PM
Re: Parsing XML with Perl - Which module
____________
Can't locate loadable object for module XML::Parser::Expat in @INC (@INC contains: /opt/aue/bin /opt/aue/lib /opt/perl5/lib/5.00503/PA-RISC2.0 /opt/perl5/lib/5.00503 /o
pt/perl5/lib/site_perl/5.005/PA-RISC2.0 /opt/perl5/lib/site_perl/5.005 .) at /opt/aue/lib/XML/Parser.pm line 15
BEGIN failed--compilation aborted at /opt/aue/lib/XML/Parser.pm line 27.
BEGIN failed--compilation aborted at ./t.pl line 12.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 06:34 PM
тАО08-07-2005 06:34 PM
Solutionas XML lends itself to being parsed through Perl, as you can imagine, there is an abundance of Perl modules available for this purpose.
So it could be difficult to decide which one to use, and it depends on the XML source you need to parse, and on what you intend to achieve.
Most XML parsers fall into two categories.
Those that parse an XML document treating it as a tree, and those which are event based
(mind you there's even a SAX implementation for Perl).
However, some also are very versatile and allow both.
There are also pure Perl modules that don't require some extra C libraries, and of course the latter.
If your parsing is simple and if you don't have to parse huge chunks of XML I would suggest XML::Simple, which doesn't require the additional installation of XML libraries.
See
http://search.cpan.org/~grantm/XML-Simple-2.14/lib/XML/Simple.pm
for details.
However, be warned that XML::Simple can have a severe time penalty (especially if your XML is vast).
Afaik, it's also not suited for XML validation against a DTD or Schema (or RelaxNG), but merely well-formedness.
If the performance is prohibitive I'd suggest you go for XML::Parser which is based on one of the oldest XML parsers going back to an implimantation of Perl inventor Larry Wall himself.
http://search.cpan.org/~msergeant/XML-Parser-2.34/Parser.pm
Thus XML::Parser possibly lacks the latest of XML specification adherence.
I'm not sure if XML::Parser would install without libexpat, but I fear not.
So you as well would need to install the C library Expat which the module has to be linked against.
http://expat.sourceforge.net/
Because XML::Parser makes use of libexpat it's really rocking fast compared to XML::Simple.
The coding also differs significantly from XML::Simple as you would have to define callback functions for XML elements you need to catch.
As anside, many newer and more specialized XML Perl modules are based on XML::Simple.
Therefore it cannot hurt to have it installed.
Have you made sure that you installed the prerequisite libexpat?
Another nifty module is XML::XPath which I think also requires XML::Parser (thus also makes use of libexpat and is equally fast)
http://search.cpan.org/~msergeant/XML-XPath-1.13/XPath.pm
It builds on the XPath specification and implements the XPath functions as Perl methods.
It's especially easy to use for people used to Unix directory paths, which can be thought of as an analogy.
Then there's another big contender XML::libXML
http://search.cpan.org/~phish/XML-LibXML-1.58/LibXML.pod
which requires the Gnome libxml2
http://xmlsoft.org/
With it you can adhere fully to XML specification as it implements the Document Object Module (DOM) as well as the Simple API to XML (SAX) which is heavily used in the Java community.
I think these are the most prominent Perl modules if you need anything to do XML.
But there are dozens of others which maybe even better serve your purpose.
I would suggest you browse through CPAN and have a look at the POD of the other modules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 07:29 PM
тАО08-07-2005 07:29 PM
Re: Parsing XML with Perl - Which module
2. Yes there is more:
lt09:/home/merijn 104 > find /pro/lib/perl5 | grep XML | grep -w -v -e SAX -e PROCURA -e Twig -e XPath
/pro/lib/perl5/site_perl/5.8.7/Pod/Simple/XMLOutStream.pm
/pro/lib/perl5/site_perl/5.8.7/Pod/Simple/DumpAsXML.pm
/pro/lib/perl5/site_perl/5.8.7/XML
/pro/lib/perl5/site_perl/5.8.7/XML/Parser
/pro/lib/perl5/site_perl/5.8.7/XML/Parser/Lite.pm
/pro/lib/perl5/site_perl/5.8.7/Apache/XMLRPC
/pro/lib/perl5/site_perl/5.8.7/Apache/XMLRPC/Lite.pm
/pro/lib/perl5/site_perl/5.8.7/XMLRPC
/pro/lib/perl5/site_perl/5.8.7/XMLRPC/Lite.pm
/pro/lib/perl5/site_perl/5.8.7/XMLRPC/Transport
/pro/lib/perl5/site_perl/5.8.7/XMLRPC/Transport/TCP.pm
/pro/lib/perl5/site_perl/5.8.7/XMLRPC/Transport/HTTP.pm
/pro/lib/perl5/site_perl/5.8.7/XMLRPC/Transport/POP3.pm
/pro/lib/perl5/site_perl/5.8.7/XMLRPC/Test.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Style
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Style/Debug.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Style/Objects.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Style/Stream.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Style/Subs.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Style/Tree.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/LWPExternEnt.pl
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Expat.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/README
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/x-euc-jp-jisx0221.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/x-sjis-unicode.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/euc-kr.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/Japanese_Encodings.msg
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/x-sjis-cp932.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/x-euc-jp-unicode.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/x-sjis-jisx0221.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/x-sjis-jdk117.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/big5.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-2.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-3.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-4.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-5.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-7.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-8.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/iso-8859-9.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/windows-1250.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser/Encodings/windows-1252.enc
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/XML/Parser.pm
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/auto/XML
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/auto/XML/Parser
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/auto/XML/Parser/Expat
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/auto/XML/Parser/Expat/Expat.bs
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/auto/XML/Parser/Expat/Expat.so
/pro/lib/perl5/site_perl/5.8.7/i686-linux-64int/auto/XML/Parser/.packlist
lt09:/home/merijn 105 >
I propose to upgrade :)
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 08:01 PM
тАО08-07-2005 08:01 PM
Re: Parsing XML with Perl - Which module
I also had a typo where I wrote that many other XML modules were "based on XML::Simple".
This of course is dead wrong and I meant XML::Parser.
Once you have a current Perl installed you should try to install your required XML modules via the CPAN module (or its successor, as procura would suggest).
The advantage of this is that it reminds you of all dependencies (which can be quite a few), and also tries to download and build them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2005 08:25 PM
тАО08-07-2005 08:25 PM
Re: Parsing XML with Perl - Which module
Upgrading to a more recent version of Perl does sound like the answer I was looking for. I will have to talk to the sys admin for these machines to see what can be done.
I will leave this thread open for a couple of days and assign points once I have digested the information and re read the posts a couple of times.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2005 12:06 PM
тАО08-09-2005 12:06 PM