.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" 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::Bare 3pm" .TH XML::Bare 3pm "2012-02-08" "perl v5.14.2" "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::Bare \- Minimal XML parser implemented via a C state engine .SH "VERSION" .IX Header "VERSION" version 0.47 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::Bare; \& \& my $ob = new XML::Bare( text => \*(AqBob\*(Aq ); \& \& # Parse the xml into a hash tree \& my $root = $ob\->parse(); \& \& # Print the content of the name node \& print $root\->{xml}\->{name}\->{value}; \& \& # \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& \& # Load xml from a file ( assume same contents as first example ) \& my $ob2 = new XML::Bare( file => \*(Aqtest.xml\*(Aq ); \& \& my $root2 = $ob2\->parse(); \& \& $root2\->{xml}\->{name}\->{value} = \*(AqTim\*(Aq; \& \& # Save the changes back to the file \& $ob2\->save(); \& \& # \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& \& # Load xml and verify against XBS ( XML Bare Schema ) \& my $xml_text = \*(Aq\*(Aq; \& my $schema_text = \*(Aq\*(Aq; \& my $ob3 = new XML::Bare( text => $xml_text, schema => { text => $schema_text } ); \& $ob3\->parse(); # this will error out if schema is invalid .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is a 'Bare' \s-1XML\s0 parser. It is implemented in C. The parser itself is a simple state engine that is less than 500 lines of C. The parser builds a C struct tree from input text. That C struct tree is converted to a Perl hash by a Perl function that makes basic calls back to the C to go through the nodes sequentially. .PP The parser itself will only cease parsing if it encounters tags that are not closed properly. All other inputs will parse, even invalid inputs. To allowing checking for validity, a schema checker is included in the module as well. .PP The schema format is custom and is meant to be as simple as possible. It is based loosely around the way multiplicity is handled in Perl regular expressions. .SS "Supported \s-1XML\s0" .IX Subsection "Supported XML" To demonstrate what sort of \s-1XML\s0 is supported, consider the following examples. Each of the \s-1PERL\s0 statements evaluates to true. .IP "\(bu" 2 Node containing just text .Sp .Vb 2 \& XML: blah \& PERL: $root\->{xml}\->{value} eq "blah"; .Ve .IP "\(bu" 2 Subset nodes .Sp .Vb 2 \& XML: Bob \& PERL: $root\->{xml}\->{name}\->{value} eq "Bob"; .Ve .IP "\(bu" 2 Attributes unquoted .Sp .Vb 2 \& XML: Link \& PERL: $root\->{xml}\->{a}\->{href}\->{value} eq "index.htm"; .Ve .IP "\(bu" 2 Attributes quoted .Sp .Vb 2 \& XML: Link \& PERL: $root\->{xml}\->{a}\->{href}\->{value} eq "index.htm"; .Ve .IP "\(bu" 2 \&\s-1CDATA\s0 nodes .Sp .Vb 2 \& XML: ]]> \& PERL: $root\->{xml}\->{raw}\->{value} eq "some raw \e$~"; .Ve .IP "\(bu" 2 Multiple nodes; form array .Sp .Vb 2 \& XML: 12 \& PERL: $root\->{xml}\->{item}\->[0]\->{value} eq "1"; .Ve .IP "\(bu" 2 Forcing array creation .Sp .Vb 2 \& XML: 1 \& PERL: $root\->{xml}\->{item}\->[0]\->{value} eq "1"; .Ve .IP "\(bu" 2 One comment supported per node .Sp .Vb 2 \& XML: \& PERL: $root\->{xml}\->{comment} eq \*(Aqtest\*(Aq; .Ve .SS "Schema Checking" .IX Subsection "Schema Checking" Schema checking is done by providing the module with an \s-1XBS\s0 (XML::Bare Schema) to check the \s-1XML\s0 against. If the \s-1XML\s0 checks as valid against the schema, parsing will continue as normal. If the \s-1XML\s0 is invalid, the parse function will die, providing information about the failure. .PP The following information is provided in the error message: .IP "\(bu" 2 The type of error .IP "\(bu" 2 Where the error occurred ( line and char ) .IP "\(bu" 2 A short snippet of the \s-1XML\s0 at the point of failure .SS "\s-1XBS\s0 ( XML::Bare Schema ) Format" .IX Subsection "XBS ( XML::Bare Schema ) Format" .IP "\(bu" 2 Required nodes .Sp .Vb 2 \& XML: \& XBS: .Ve .IP "\(bu" 2 Optional nodes \- allow one .Sp .Vb 3 \& XML: \& XBS: \& or XBS: .Ve .IP "\(bu" 2 Optional nodes \- allow 0 or more .Sp .Vb 2 \& XML: \& XBS: .Ve .IP "\(bu" 2 Required nodes \- allow 1 or more .Sp .Vb 2 \& XML: \& XBS: .Ve .IP "\(bu" 2 Nodes \- specified minimum and maximum number .Sp .Vb 4 \& XML: \& XBS: \& or XBS: \& or XBS: .Ve .IP "\(bu" 2 Multiple acceptable node formats .Sp .Vb 2 \& XML: \& XBS: .Ve .IP "\(bu" 2 Regular expressions checking for values .Sp .Vb 2 \& XML: \& XBS: .Ve .IP "\(bu" 2 Require multi_ tags .Sp .Vb 2 \& XML: \& XBS: .Ve .SS "Parsed Hash Structure" .IX Subsection "Parsed Hash Structure" The hash structure returned from \s-1XML\s0 parsing is created in a specific format. Besides as described above, the structure contains some additional nodes in order to preserve information that will allow that structure to be correctly converted back to \s-1XML\s0. .PP Nodes may contain the following 3 additional subnodes: .IP "\(bu" 2 _i .Sp The character offset within the original parsed \s-1XML\s0 of where the node begins. This is used to provide line information for errors when \s-1XML\s0 fails a schema check. .IP "\(bu" 2 _pos .Sp This is a number indicating the ordering of nodes. It is used to allow items in a perl hash to be sorted when writing back to xml. Note that items are not sorted after parsing in order to save time if all you are doing is reading and you do not care about the order. .Sp In future versions of this module an option will be added to allow you to sort your nodes so that you can read them in order. ( note that multiple nodes of the same name are stored in order ) .IP "\(bu" 2 _att .Sp This is a boolean value that exists and is 1 iff the node is an attribute. .SS "Parsing Limitations / Features" .IX Subsection "Parsing Limitations / Features" .IP "\(bu" 2 \&\s-1CDATA\s0 parsed correctly, but stripped if unneeded .Sp Currently the contents of a node that are \s-1CDATA\s0 are read and put into the value hash, but the hash structure does not have a value indicating the node contains \s-1CDATA\s0. .Sp When converting back to \s-1XML\s0, the contents of the value hash are parsed to check for xml incompatible data using a regular expression. If '\s-1CDATA\s0 like' stuff is encountered, the node is output as \s-1CDATA\s0. .IP "\(bu" 2 Standard \s-1XML\s0 quoted characters are decoded .Sp The basic \s-1XML\s0 quoted characters \- \f(CW\*(C`&\*(C'\fR \f(CW\*(C`>\*(C'\fR \f(CW\*(C`<\*(C'\fR \f(CW\*(C`quot;\*(C'\fR and \f(CW\*(C`'\*(C'\fR \- are recognised and decoded when reading values. However when writing the builder will put any values that need quoting into a \s-1CDATA\s0 wrapper as described above. .IP "\(bu" 2 Node position stored, but hash remains unsorted .Sp The ordering of nodes is noted using the '_pos' value, but the hash itself is not ordered after parsing. Currently items will be out of order when looking at them in the hash. .Sp Note that when converted back to \s-1XML\s0, the nodes are then sorted and output in the correct order to \s-1XML\s0. Note that nodes of the same name with the same parent will be grouped together; the position of the first item to appear will determine the output position of the group. .IP "\(bu" 2 Comments are parsed but only one is stored per node. .Sp For each node, there can be a comment within it, and that comment will be saved and output back when dumping to \s-1XML\s0. .IP "\(bu" 2 Comments override output of immediate value .Sp If a node contains only a comment node and a text value, only the comment node will be displayed. This is in line with treating a comment node as a node and only displaying immediate values when a node contains no subnodes. .IP "\(bu" 2 \&\s-1PI\s0 sections are parsed, but discarded .IP "\(bu" 2 Unknown \f(CW\*(C`texttext2 \& ( the value of node is text ) \& \& text \& ( the value of node is text ) \& \& \& text \& \& ( the value of node is "\en " ) .Ve .SS "Module Functions" .IX Subsection "Module Functions" .IP "\(bu" 2 \&\f(CW\*(C`$ob = new XML::Bare( text => "[some xml]" )\*(C'\fR .Sp Create a new \s-1XML\s0 object, with the given text as the xml source. .IP "\(bu" 2 \&\f(CW\*(C`$object = new XML::Bare( file => "[filename]" )\*(C'\fR .Sp Create a new \s-1XML\s0 object, with the given filename/path as the xml source .IP "\(bu" 2 \&\f(CW\*(C`$object = new XML::Bare( text => "[some xml]", file => "[filename]" )\*(C'\fR .Sp Create a new \s-1XML\s0 object, with the given text as the xml input, and the given filename/path as the potential output ( used by \fIsave()\fR ) .IP "\(bu" 2 \&\f(CW\*(C`$object = new XML::Bare( file => "data.xml", scheme => { file => "scheme.xbs" } )\*(C'\fR .Sp Create a new \s-1XML\s0 object and check to ensure it is valid xml by way of the \s-1XBS\s0 scheme. .IP "\(bu" 2 \&\f(CW\*(C`$tree = $object\->parse()\*(C'\fR .Sp Parse the xml of the object and return a tree reference .IP "\(bu" 2 \&\f(CW\*(C`$tree = $object\->simple()\*(C'\fR .Sp Alternate to the parse function which generates a tree similar to that generated by XML::Simple. Note that the sets of nodes are turned into arrays always, regardless of whether they have a 'name' attribute, unlike XML::Simple. .Sp Note that currently the generated tree cannot be used with any of the functions in this module that operate upon trees. The function is provided purely as a quick and dirty way to read simple \s-1XML\s0 files. .IP "\(bu" 2 \&\f(CW\*(C`$tree = xmlin( $xmlext, keeproot => 1 )\*(C'\fR .Sp The xmlin function is a shortcut to creating an XML::Bare object and parsing it using the simple function. It behaves similarly to the XML::Simple function by the same name. The keeproot option is optional and if left out the root node will be discarded, same as the function in XML::Simple. .IP "\(bu" 2 \&\f(CW\*(C`$text = $object\->xml( [root] )\*(C'\fR .Sp Take the hash tree in [root] and turn it into cleanly indented ( 2 spaces ) \&\s-1XML\s0 text. .IP "\(bu" 2 \&\f(CW\*(C`$text = $object\->html( [root], [root node name] )\*(C'\fR .Sp Take the hash tree in [root] and turn it into nicely colorized and styled html. [root node name] is optional. .IP "\(bu" 2 \&\f(CW\*(C`$object\->save()\*(C'\fR .Sp The the current tree in the object, cleanly indent it, and save it to the file parameter specified when creating the object. .IP "\(bu" 2 \&\f(CW\*(C`$value = xval $node, $default\*(C'\fR .Sp Returns the value of \f(CW$node\fR or \f(CW$default\fR if the node does not exist. If default is not passed to the function, then '' is returned as a default value when the node does not exist. .IP "\(bu" 2 \&\f(CW\*(C`( $name, $age ) = xget( $personnode, qw/name age/ )\*(C'\fR .Sp Shortcut function to grab a number of values from a node all at the same time. Note that this function assumes that all of the subnodes exist; it will fail if they do not. .IP "\(bu" 2 \&\f(CW\*(C`$text = XML::Bare::clean( text => "[some xml]" )\*(C'\fR .Sp Shortcut to creating an xml object and immediately turning it into clean xml text. .IP "\(bu" 2 \&\f(CW\*(C`$text = XML::Bare::clean( file => "[filename]" )\*(C'\fR .Sp Similar to previous. .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::clean( file => "[filename]", save => 1 )\*(C'\fR .Sp Clean up the xml in the file, saving the results back to the file .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::clean( text => "[some xml]", save => "[filename]" )\*(C'\fR .Sp Clean up the xml provided, and save it into the specified file. .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::clean( file => "[filename1]", save => "[filename2]" )\*(C'\fR .Sp Clean up the xml in filename1 and save the results to filename2. .IP "\(bu" 2 \&\f(CW\*(C`$html = XML::Bare::tohtml( text => "[some xml]", root => \*(Aqxml\*(Aq )\*(C'\fR .Sp Shortcut to creating an xml object and immediately turning it into html. Root is optional, and specifies the name of the root node for the xml ( which defaults to 'xml' ) .IP "\(bu" 2 \&\f(CW\*(C`$object\->add_node( [node], [nodeset name], name => value, name2 => value2, ... )\*(C'\fR .Sp .Vb 2 \& Example: \& $object\->add_node( $root\->{xml}, \*(Aqitem\*(Aq, name => \*(AqBob\*(Aq ); \& \& Result: \& \& \& Bob \& \& .Ve .IP "\(bu" 2 \&\f(CW\*(C`$object\->add_node_after( [node], [subnode within node to add after], [nodeset name], ... )\*(C'\fR .IP "\(bu" 2 \&\f(CW\*(C`$object\->del_node( [node], [nodeset name], name => value )\*(C'\fR .Sp .Vb 10 \& Example: \& Starting XML: \& \& \& 1 \& \& \& 2 \& \& \& \& Code: \& $xml\->del_node( $root\->{xml}, \*(Aqa\*(Aq, b=>\*(Aq1\*(Aq ); \& \& Ending XML: \& \& \& 2 \& \& .Ve .IP "\(bu" 2 \&\f(CW\*(C`$object\->find_node( [node], [nodeset name], name => value )\*(C'\fR .Sp .Vb 12 \& Example: \& Starting XML: \& \& \& 1 \& a \& \& \& 2 \& b \& \& \& \& Code: \& $object\->find_node( $root\->{xml}, \*(Aqob\*(Aq, key => \*(Aq1\*(Aq )\->{val}\->{value} = \*(Aqtest\*(Aq; \& \& Ending XML: \& \& \& 1 \& test \& \& \& 2 \& b \& \& .Ve .IP "\(bu" 2 \&\f(CW\*(C`$object\->find_by_perl( [nodeset], "[perl code]" )\*(C'\fR .Sp find_by_perl evaluates some perl code for each node in a set of nodes, and returns the nodes where the perl code evaluates as true. In order to easily reference node values, node values can be directly referred to from within the perl code by the name of the node with a dash(\-) in front of the name. See the example below. .Sp Note that this function returns an array reference as opposed to a single node unlike the find_node function. .Sp .Vb 12 \& Example: \& Starting XML: \& \& \& 1 \& a \& \& \& 2 \& b \& \& \& \& Code: \& $object\->find_by_perl( $root\->{xml}\->{ob}, "\-key eq \*(Aq1\*(Aq" )\->[0]\->{val}\->{value} = \*(Aqtest\*(Aq; \& \& Ending XML: \& \& \& 1 \& test \& \& \& 2 \& b \& \& .Ve .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::merge( [nodeset1], [nodeset2], [id node name] )\*(C'\fR .Sp Merges the nodes from nodeset2 into nodeset1, matching the contents of each node based up the content in the id node. .Sp Example: .Sp .Vb 10 \& Code: \& my $ob1 = new XML::Bare( text => " \& \& \& bob \& \& 1 \& blue \& \& " ); \& my $ob2 = new XML::Bare( text => " \& \& \& john \& \& 1 \& bob \& 1 \& \& " ); \& my $root1 = $ob1\->parse(); \& my $root2 = $ob2\->parse(); \& merge( $root1\->{\*(Aqxml\*(Aq}\->{\*(Aqa\*(Aq}, $root2\->{\*(Aqxml\*(Aq}\->{\*(Aqa\*(Aq}, \*(Aqid\*(Aq ); \& print $ob1\->xml( $root1 ); \& \& Output: \& \& \& bob \& \& 1 \& blue \& bob \& 1 \& \& .Ve .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::del_by_perl( ... )\*(C'\fR .Sp Works exactly like find_by_perl, but deletes whatever matches. .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::forcearray( [noderef] )\*(C'\fR .Sp Turns the node reference into an array reference, whether that node is just a single node, or is already an array reference. .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::new_node( ... )\*(C'\fR .Sp Creates a new node... .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::newhash( ... )\*(C'\fR .Sp Creates a new hash with the specified value. .IP "\(bu" 2 \&\f(CW\*(C`XML::Bare::simplify( [noderef] )\*(C'\fR .Sp Take a node with children that have immediate values and creates a hashref to reference those values by the name of each child. .SS "Functions Used Internally" .IX Subsection "Functions Used Internally" .IP "\(bu" 2 \&\f(CW\*(C`check() checkone() readxbs() free_tree_c()\*(C'\fR .IP "\(bu" 2 \&\f(CW\*(C`lineinfo() c_parse() c_parsefile() free_tree() xml2obj()\*(C'\fR .IP "\(bu" 2 \&\f(CW\*(C`obj2xml() get_root() obj2html() xml2obj_simple()\*(C'\fR .SS "Performance" .IX Subsection "Performance" In comparison to other available perl xml parsers that create trees, XML::Bare is extremely fast. In order to measure the performance of loading and parsing compared to the alternatives, a templated speed comparison mechanism has been created and included with XML::Bare. .PP The include makebench.pl file runs when you make the module and creates perl files within the bench directory corresponding to the .tmpl contained there. .PP Currently there are three types of modules that can be tested against, executable parsers ( exe.tmpl ), tree parsers ( tree.tmpl ), and parsers that do not generated trees ( notree.tmpl ). .PP A full list of modules currently tested against is as follows: .PP .Vb 10 \& Tiny XML (exe) \& EzXML (exe) \& XMLIO (exe) \& XML::LibXML (notree) \& XML::Parser (notree) \& XML::Parser::Expat (notree) \& XML::Descent (notree) \& XML::Parser::EasyTree \& XML::Handler::Trees \& XML::Twig \& XML::Smart \& XML::Simple using XML::Parser \& XML::Simple using XML::SAX::PurePerl \& XML::Simple using XML::LibXML::SAX::Parser \& XML::Simple using XML::Bare::SAX::Parser \& XML::TreePP \& XML::Trivial \& XML::SAX::Simple \& XML::Grove::Builder \& XML::XPath::XMLParser \& XML::DOM .Ve .PP To run the comparisons, run the appropriate perl file within the bench directory. ( exe.pl, tree.pl, or notree.pl ) .PP The script measures the milliseconds of loading and parsing, and compares the time against the time of XML::Bare. So a 7 means it takes 7 times as long as XML::Bare. .PP Here is a combined table of the script run against each alternative using the included test.xml: .PP .Vb 10 \& \-Module\- load parse total \& XML::Bare 1 1 1 \& XML::TreePP 2.3063 33.1776 6.1598 \& XML::Parser::EasyTree 4.9405 25.7278 7.4571 \& XML::Handler::Trees 7.2303 26.5688 9.6447 \& XML::Trivial 5.0636 12.4715 7.3046 \& XML::Smart 6.8138 78.7939 15.8296 \& XML::Simple (XML::Parser) 2.3346 50.4772 10.7455 \& XML::Simple (PurePerl) 2.361 261.4571 33.6524 \& XML::Simple (LibXML) 2.3187 163.7501 23.1816 \& XML::Simple (XML::Bare) 2.3252 59.1254 10.9163 \& XML::SAX::Simple 8.7792 170.7313 28.3634 \& XML::Twig 27.8266 56.4476 31.3594 \& XML::Grove::Builder 7.1267 26.1672 9.4064 \& XML::XPath::XMLParser 9.7783 35.5486 13.0002 \& XML::LibXML (notree) 11.0038 4.5758 10.6881 \& XML::Parser (notree) 4.4698 17.6448 5.8609 \& XML::Parser::Expat(notree) 3.7681 50.0382 6.0069 \& XML::Descent (notree) 6.0525 37.0265 11.0322 \& Tiny XML (exe) 1.0095 \& EzXML (exe) 1.1284 \& XMLIO (exe) 1.0165 .Ve .PP Here is a combined table of the script run against each alternative using the included feed2.xml: .PP .Vb 10 \& \-Module\- load parse total \& XML::Bare 1 1 1 \& XML::TreePP 2.3068 23.7554 7.6921 \& XML::Parser::EasyTree 4.8799 25.3691 9.6257 \& XML::Handler::Trees 6.8545 33.1007 13.0575 \& XML::Trivial 5.0105 32.0043 11.4113 \& XML::Simple (XML::Parser) 2.3498 41.9007 12.3062 \& XML::Simple (PurePerl) 2.3551 224.3027 51.7832 \& XML::Simple (LibXML) 2.3617 88.8741 23.215 \& XML::Simple (XML::Bare) 2.4319 37.7355 10.2343 \& XML::Simple 2.7168 90.7203 26.7525 \& XML::SAX::Simple 8.7386 94.8276 29.2166 \& XML::Twig 28.3206 48.1014 33.1222 \& XML::Grove::Builder 7.2021 30.7926 12.9334 \& XML::XPath::XMLParser 9.6869 43.5032 17.4941 \& XML::LibXML (notree) 11.0023 5.022 10.5214 \& XML::Parser (notree) 4.3748 25.0213 5.9803 \& XML::Parser::Expat(notree) 3.6555 51.6426 7.4316 \& XML::Descent (notree) 5.9206 155.0289 18.7767 \& Tiny XML (exe) 1.2212 \& EzXML (exe) 1.3618 \& XMLIO (exe) 1.0145 .Ve .PP These results show that XML::Bare is, at least on the test machine, running all tests within cygwin, faster at loading and parsing than everything being tested against. .PP The following things are shown as well: \- XML::Bare can parse \s-1XML\s0 and create a hash tree in less time than it takes LibXML just to parse. \- XML::Bare can parse \s-1XML\s0 and create a tree in less time than all three binary parsers take just to parse. .PP Note that the executable parsers are not perl modules and are timed using dummy programs that just uses the library to load and parse the example files. The executables are not included with this program. Any source modifications used to generate the shown test results can be found in the bench/src directory of the distribution .SH "CONTRIBUTED CODE" .IX Header "CONTRIBUTED CODE" The \s-1XML\s0 dequoting code used is taken from XML::Quote by \fISergey Skvortsov\fR (\fI\s-1GDSL\s0\fR on \s-1CPAN\s0) with very minor modifications. .SH "INSTALLATION" .IX Header "INSTALLATION" See perlmodinstall for information and options on installing Perl modules. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" No bugs have been reported. .PP Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=XML\-Bare . .SH "AVAILABILITY" .IX Header "AVAILABILITY" The project homepage is https://metacpan.org/release/XML\-Bare . .PP The latest version of this module is available from the Comprehensive Perl Archive Network (\s-1CPAN\s0). Visit to find a \s-1CPAN\s0 site near you, or see http://search.cpan.org/dist/XML\-Bare/ . .PP The development version lives at http://github.com/nigelm/xml\-bare and may be cloned from git://github.com/nigelm/xml\-bare.git . Instead of sending patches, please fork this project using the standard git and github infrastructure. .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 David Helkowski .IP "\(bu" 4 Nigel Metheringham .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2012 by David Helkowski. .PP This is free software, licensed under: .PP .Vb 1 \& The GNU General Public License, Version 2, June 1991 .Ve