[XML4Lib] document object model

Brian Sheppard bboru at umich.edu
Tue Aug 15 11:50:44 EDT 2006


Eric, DLXS middleware makes use of XML::LibXSLT and XML::LibXML. The  
source code is avaiable from dlxs.org.

For very simple processing, XML::Simple is an option. For example,  
for the file "histConfig.xml,"

<?xml version="1.0" encoding="utf-8"?>
<collection>
   <development>
     <meta>
       <collid>hist</collid>
       <collTitle>A Comprehensive History of Knowledge</collTitle>
       <priority>10</priority>
     </meta>
   </development>
</collection>

The following will get the value of the 'priority' element.

#####################

use XML::Simple;

my $gConfigFile = q{histConfig.xml};
my $priority = &GetConfigFileSettings( $gConfigFile );

sub GetConfigFileSettings
{
     my $configFile    = shift;

     my $parser = XML::Simple->new();
     # express the document as a hash
     my $doc    = $parser->XMLin( $configFile );

     # error check
     ASSERT( $doc, qq{Unable to parse $configFile } );

     my $priority = $doc->{ 'development' }->{ 'meta' }->{ 'priority' };

     # error check
     ASSERT( $priority, qq{Unable to fathom the priority value in  
$configFile" } );

     return ( $priority );
}


On August 15, at 7:58 AM, Eric Lease Morgan wrote:

> Can y'all point me to some normative examples of the document  
> object model implemented in Perl?
>
> I have some simple XML documents I want to read. For better or for  
> worse I want to use DOM (not SAX, and certainly not regular  
> expressions) to extract the data I require. There are at least a  
> couple of Perl modules allowing me to do this: XML::DOM and  
> XML:LibXML. Unfortunately, both modules point me to the official  
> W3C DOM documentation, and that documentation is too heavy for me.

------------------------------------------------------------------------ 
---------------------
Brian Sheppard
bboru at umich.edu
------------------------------------------------------------------------ 
---------------------
"J'appuyais tendrement mes joues contre les belles joues de l'oreiller,
qui, pleines et fraîches, sont comme les joues de notre enfance."






More information about the XML4Lib mailing list