Bare(3)

🌸 NAME 🌸

XML::Bare β€” Minimal XML parser implemented via a C state engine. yep, this is the Bare(3) page, and it's lowkey a whole vibe. πŸ’…

✨ VERSION ✨

0.53 β€” periodt.

πŸ¦‹ SYNOPSIS πŸ¦‹

okay bestie, here's the group-chat recap of how you use it:

use XML::Bare;

my $ob = new XML::Bare( text => '<xml><name>Bob</name></xml>' );

# 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 => 'test.xml' );

my $root2 = $ob2->parse();

$root2->{xml}->{name}->{value} = 'Tim';

# Save the changes back to the file
$ob2->save();

---

# Load xml and verify against XBS ( XML Bare Schema )
my $xml_text = '<xml><item name=bob/></xml>''
my $schema_text = '<xml><item* name=[a-z]+></item*></xml>'
my $ob = new XML::Bare( text => $xml_text, schema => { text => $schema_text } );
$ob->parse(); # this will error out if schema is invalid

πŸ’– DESCRIPTION πŸ’–

okay so this module is a 'Bare' XML parser, and it's implemented in C. the parser itself is a simple state engine that is less than 500 lines of C. it builds a C struct tree from the input text, and then that C struct tree gets converted to a Perl hash by a Perl function that makes basic calls back to the C to go through the nodes sequentially. it's giving tiny-but-does-the-job energy. 🫢

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 allow checking for validity, a schema checker is included in the module as well. yes, that's the safety net. πŸŽ€

the schema format is custom and is meant to be as simple as possible. it's based loosely around the way multiplicity is handled in Perl regular expressions. cute, right? ✨


🌈 Supported XML 🌈

to demonstrate what sort of XML is supported, consider the following examples. each of the PERL statements evaluates to true. no cap. πŸ‘‘

  • Node containing just text β€” this one's giving "basic but valid":
XML: <xml>blah</xml>
PERL: $root->{xml}->{value} eq "blah";
  • Subset nodes β€” nested cuties:
XML: <xml><name>Bob</name></xml>
PERL: $root->{xml}->{name}->{value} eq "Bob";
  • Attributes unquoted β€” the parser said "quotes are optional, bestie":
XML: <xml><a href=index.htm>Link</a></xml>
PERL: $root->{xml}->{a}->{href}->{value} eq "index.htm";
  • Attributes quoted β€” same energy, but dressed up:
XML: <xml><a href="index.htm">Link</a></xml>
PERL: $root->{xml}->{a}->{href}->{value} eq "index.htm";
  • CDATA nodes β€” raw text moment:
XML: <xml><raw><![CDATA[some raw $~<!bad xml<>]]></raw></xml>
PERL: $root->{xml}->{raw}->{value} eq "some raw \$~<!bad xml<>";
  • Multiple nodes; form array β€” when there's more than one, it's an array situation:
XML: <xml><item>1</item><item>2</item></xml>
PERL: $root->{xml}->{item}->[0]->{value} eq "1";
  • Forcing array creation β€” yes, you can make it array even with one item:
XML: <xml><multi_item/><item>1</item></xml>
PERL: $root->{xml}->{item}->[0]->{value} eq "1";
  • One comment supported per node β€” just one, don't be greedy:
XML: <xml><!--test--></xml>
PERL: $root->{xml}->{comment} eq 'test';

πŸŽ€ Schema Checking πŸŽ€

schema checking is done by providing the module with an XBS ( XML::Bare Schema ) to check the XML against. if the XML checks as valid against the schema, parsing will continue as normal. if the XML is invalid, the parse function will die, providing information about the failure. πŸ’€

the following information is provided in the error message:

  • the type of error
  • where the error occurred ( line and char )
  • a short snippet of the XML at the point of failure

🧚 XBS ( XML::Bare Schema ) Format 🧚

okay here's the schema format, and it's honestly slay:

  • Required nodes β€” must be there, no exceptions:
XML: <xml></xml>
XBS: <xml/>
  • Optional nodes - allow one β€” zero or one, choose your fighter:
XML: <xml></xml>
XBS: <xml item?/>
or XBS: <xml><item?/></xml>
  • Optional nodes - allow 0 or more β€” the "go off, have as many as you want" special:
XML: <xml><item/></xml>
XBS: <xml item*/>
  • Required nodes - allow 1 or more β€” at least one, bestie:
XML: <xml><item/><item/></xml>
XBS: <xml item+/>
  • Nodes - specified minimum and maximum number β€” set the range, set the boundaries:
XML: <xml><item/><item/></xml>
XBS: <xml item{1,2}/>
or XBS: <xml><item{1,2}/></xml>
or XBS: <xml><item{1,2}></item{1,2}></xml>
  • Multiple acceptable node formats β€” different shapes, same approval:
XML: <xml><item type=box volume=20/><item type=line length=10/></xml>
XBS: <xml><item type=box volume/><item type=line length/></xml>
  • Regular expressions checking for values β€” regex girlies rise up:
XML: <xml name=Bob dir=up num=10/>
XBS: <xml name=[A-Za-z]+ dir=up|down num=[0-9]+/>
  • Require multi_ tags β€” special multi_ tag behavior:
XML: <xml><multi_item/></xml>
XBS: <xml item@/>

πŸ‘‘ Parsed Hash Structure πŸ‘‘

the hash structure returned from XML 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 XML.

nodes may contain the following 3 additional subnodes:

  • _i β€” the character offset within the original parsed XML of where the node begins. this is used to provide line information for errors when XML fails a schema check.
  • _pos β€” 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. 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 )
  • _att β€” this is a boolean value that exists and is 1 iff the node is an attribute.

πŸ”₯ Parsing Limitations / Features πŸ”₯

  • CDATA parsed correctly, but stripped if unneeded β€” currently the contents of a node that are CDATA are read and put into the value hash, but the hash structure does not have a value indicating the node contains CDATA. when converting back to XML, the contents of the value hash are parsed to check for xml incompatible data using a regular expression. if 'CDATA like' stuff is encountered, the node is output as CDATA.
  • Node position stored, but hash remains unsorted β€” 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. note that when converted back to XML, the nodes are then sorted and output in the correct order to XML. 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.
  • Comments are parsed but only one is stored per node. for each node, there can be a comment within it, and that comment will be saved and output back when dumping to XML.
  • Comments override output of immediate value β€” 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.
  • PI sections are parsed, but discarded.
  • Unknown <! sections are parsed, but discarded.
  • Attributes may use no quotes, single quotes, quotes, or backtics.
  • Quoted attributes cannot contain escaped quotes β€” no escape character is recognized within quotes. as a result, regular quotes cannot be stored to XML, or the written XML will not be correct, due to all attributes always being written using quotes. 😭
  • Attributes are always written back to XML with quotes.
  • Nodes cannot contain subnodes as well as an immediate value β€” actually nodes can in fact contain a value as well, but that value will be discarded if you write back to XML. that value is equal to the first continuous string of text besides a subnode.
<node>text<subnode/>text2</node>
( the value of node is text )

<node><subnode/>text</node>
( the value of node is text )

<node>
  <subnode/>text
</node>
( the value of node is "\n  " )
  • Entities are not parsed β€” no entity parsing is done. this is intentional. future versions of the module may include a feature to automatically parse entities, but by default any such feature will be disabled in order to keep from slowing down the parser. also, this is done so that round trip ( read and then write back out ) behavior is consistent.
  • Nodes named value β€” previously iterations of this module had problems with nodes named 'value', due to the fact that node contents are stored under the 'value' key already. the current version should parse such files without any problem, although it may be confusing to see a parsed tree with 'value' pointing to another hash containing 'value' as well. in a future version of the module it will be possible to alter the name that values are stored under. note that node values are stored under the key 'content' when the "simple" parsing mode is used, so as to be consistent with XML::Simple.

πŸ’… Module Functions πŸ’…

  • "$ob = XML::Bare->new( text => "[some xml]" )" β€” create a new XML object, with the given text as the xml source.
  • "$object = XML::Bare->new( file => "[filename]" )" β€” create a new XML object, with the given filename/path as the xml source.
  • "$object = XML::Bare->new( text => "[some xml]", file => "[filename]" )" β€” create a new XML object, with the given text as the xml input, and the given filename/path as the potential output ( used by save() ).
  • "$object = XML::Bare->new( file => "data.xml", scheme => { file => "scheme.xbs" } )" β€” create a new XML object and check to ensure it is valid xml by way of the XBS scheme.
  • "$tree = $object->parse()" β€” parse the xml of the object and return a tree reference.
  • "$tree = $object->simple()" β€” 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. 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 XML files.
  • "$tree = xmlin( $xmlext, keeproot => 1 )" β€” 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.
  • "$text = $object->xml( [root] )" β€” take the hash tree in [root] and turn it into cleanly indented ( 2 spaces ) XML text.
  • $text = $object->html( [root], [root node name] ) β€” bestie, this one takes the hash tree hanging out in [root] and turns it into straight-up gorgeous, colorized-and-styled HTML πŸ’…. The [root node name] part is optional, no pressure.
  • $object->save() β€” takes the current tree chilling inside the object, indents it all neat and pretty (clean girl aesthetic ✨), and saves it to the file you specified back when you created the object. Iconic, low-effort, done.
  • $value = xval $node, $default β€” hands you back the value of $node, or $default if that node literally does not exist. And if you don't pass a default at all, then '' is what you get when the node's a no-show. It's giving backup plan 🫢.
  • ( $name, $age ) = xget( $personnode, qw/name age/ ) β€” a lil shortcut that grabs a bunch of values from a node all at once. > Heads up though: this function assumes all of the subnodes exist β€” it will fail if they don't. No cap, it's not doing a vibe check first 😭.
  • $text = XML::Bare::clean( text => "[some xml]" ) β€” shortcut city: makes an xml object and immediately turns it into clean xml text. πŸŽ€
  • $text = XML::Bare::clean( file => "[filename]" ) β€” same energy as the previous one, just from a file instead.
  • XML::Bare::clean( file => "[filename]", save => 1 ) β€” cleans up the xml in the file and saves the results right back into that same file. In-place glow-up πŸ’–.
  • XML::Bare::clean( text => "[some xml]", save => "[filename]" ) β€” cleans up the xml you gave it, then saves it into the specified file.
  • XML::Bare::clean( file => "[filename1]", save => "[filename2]" ) β€” cleans up the xml in filename1 and saves the results to filename2.
  • $html = XML::Bare::tohtml( text => "[some xml]", root => 'xml' ) β€” shortcut to making an xml object and immediately turning it into html ✨. root is optional and names the root node for the xml (which defaults to 'xml').
  • $object->add_node( [node], [nodeset name], name => value, name2 => value2, ... ) β€” adds a node. Watch:

Example:

$object->add_node( $root->{xml}, 'item', name => 'Bob' );

Result:

<xml>
  <item>
    <name>Bob</name>
  </item>
</xml>
  • $object->add_node_after( [node], [subnode within node to add after], [nodeset name], ... ) β€” exactly what it says on the tin, it adds the node after the subnode you point at πŸ¦‹.
  • $object->del_node( [node], [nodeset name], name => value ) β€” deletes matching nodes. Let me show you:

Example β€” starting XML:

<xml>
  <a>
    <b>1</b>
  </a>
  <a>
    <b>2</b>
  </a>
</xml>

Code:

$xml->del_node( $root->{xml}, 'a', b=>'1' );

Ending XML:

<xml>
  <a>
    <b>2</b>
  </a>
</xml>
  • $object->find_node( [node], [nodeset name], name => value ) β€” finds a node, returns it, and you can just keep walking down it like it's nothing πŸ”₯:

Example β€” starting XML:

<xml>
  <ob>
    <key>1</key>
    <val>a</val>
  </ob>
  <ob>
    <key>2</key>
    <val>b</val>
  </ob>
</xml>

Code:

$object->find_node( $root->{xml}, 'ob', key => '1' )->{val}->{value} = 'test';

Ending XML:

<xml>
  <ob>
    <key>1</key>
    <val>test</val>
  </ob>
  <ob>
    <key>2</key>
    <val>b</val>
  </ob>
</xml>
  • $object->find_by_perl( [nodeset], "[perl code]" ) β€” ok so this one evaluates some perl code for each node in a set of nodes, and returns the nodes where the perl code evaluates as true. And to make referencing node values super easy, you can refer to node values directly from inside the perl code by just writing the name of the node with a dash (-) in front of it. Example's below, bestie πŸ’œ.
Big note: this function returns an array reference, not a single node β€” unlike find_node. Don't get caught out 😭.

Example β€” starting XML:

<xml>
  <ob>
    <key>1</key>
    <val>a</val>
  </ob>
  <ob>
    <key>2</key>
    <val>b</val>
  </ob>
</xml>

Code:

$object->find_by_perl( $root->{xml}->{ob}, "-key eq '1'" )->[0]->{val}->{value} = 'test';

Ending XML:

<xml>
  <ob>
    <key>1</key>
    <val>test</val>
  </ob>
  <ob>
    <key>2</key>
    <val>b</val>
  </ob>
</xml>
  • XML::Bare::merge( [nodeset1], [nodeset2], [id node name] ) β€” merges the nodes from nodeset2 into nodeset1, matching the contents of each node based up the content in the id node. Slay, combining friend groups 🫢.

Example:

Code:

my $ob1 = new XML::Bare( text => "
  <xml>
    <multi_a/>
    <a>bob</a>
    <a>
      <id>1</id>
      <color>blue</color>
    </a>
  </xml>" );
my $ob2 = new XML::Bare( text => "
  <xml>
    <multi_a/>
    <a>john</a>
    <a>
      <id>1</id>
      <name>bob</name>
      <bob>1</bob>
    </a>
  </xml>" );
my $root1 = $ob1->parse();
my $root2 = $ob2->parse();
merge( $root1->{'xml'}->{'a'}, $root2->{'xml'}->{'a'}, 'id' );
print $ob1->xml( $root1 );

Output:

<xml>
  <multi_a></multi_a>
  <a>bob</a>
  <a>
    <id>1</id>
    <color>blue</color>
    <name>bob</name>
    <bob>1</bob>
  </a>
</xml>
  • XML::Bare::del_by_perl( ... ) β€” works exactly like find_by_perl, except it deletes whatever matches. Ghosting, but for nodes πŸ’€.
  • XML::Bare::forcearray( [noderef] ) β€” turns the node reference into an array reference, whether that node is just a single node, or is already an array reference. Either way, it eats πŸ“.
  • XML::Bare::new_node( ... ) β€” creates a new node... (that's the whole description, she's mysterious like that πŸ™ˆ)
  • XML::Bare::newhash( ... ) β€” creates a new hash with the specified value.
  • XML::Bare::simplify( [noderef] ) β€” takes a node with children that have immediate values and creates a hashref to reference those values by the name of each child. So tidy ✨.
  • XML::Bare::hash2xml( [hashref] ) β€” takes a recursive hash tree (maybe one you got from the simplify function) and turns it into a raw XML string. > Warning bestie: this function does not indent nicely. You'll need to feed that string back into the parser and output it again if you want it to look nice β€” or you could use the 'clean' function to do it in one go πŸŽ€.
  • XML::Bare->new( text => "[xml]", unsafe => 1 ) β€” an extra speedy way to parse XML. It is unsafe; may harm pets and children 😭. Don't say you weren't warned. 30% speed boost compared to the normal parsing. You must use $ob->simple() in combination with this for it to work properly.

The speed boost is gained by skipping checks for the end of the string when in the middle of properly formatted XML. The only time the check is done is within "values" (which includes the space after the final closing </xml>).

Also, in the unsafe mode, tags β€” complete with their attributes β€” must be on one line. Node contents of course can still have carriage returns... 🌈

  • $object->read_more( text => "[xml fragment]" ) β€” adds more XML text to be handled. > Note that this function must be called before calling the parse function. No sneaky post-parse additions πŸ™…β€β™€οΈ.

Example:

Code:

my $ob = XML::Bare->new( text => "
  <xml>
    <node>a</node>" );
$ob->read_more( text => "<node>b</node>" );
$ob->read_more( text => "</xml>" );
my $root = $ob->parse();
print $ob->xml( $root );

Output:

<xml>
  <node>a</node>
  <node>b</node>
</xml>
Warning! Reading in additional XML fragments only works properly at proper "division points". Currently the parser will not work properly if you split in the middle of a node value, or in the middle of a node name. A future version of the module will be properly updated to handle these cases. πŸ’€

Currently there is little to no benefit to parsing this way, rather than simple concatenating the two strings together and then reading all the XML in at once. Like, just saying πŸ€·β€β™€οΈ.

πŸ› οΈ Functions Used Internally πŸ› οΈ

These are the behind-the-scenes girlies β€” not really for you, but here they all are, iykyk:

  • check() checkone() readxbs() free_tree_c()
  • lineinfo() c_parse() c_parse_unsafely() c_parse_more() c_parsefile() free_tree() xml2obj()
  • obj2xml() get_root() obj2html() xml2obj_simple()

βš”οΈ Controversy βš”οΈ

Okay so since this module was created there's been a fair amount of controvesy surrounding it 😬. A number of authors of other XML parsers have gone so far as to publicly attack this module and claim that it 'does not parse XML', and 'it is not XML compliant'. Some of the same people seem to be angered by the inclusion of a benchmark, claiming that it is an unfair comparison, and that if the proper options and setup are used, that other XML parsers are better.

The module should parse any XML document that conforms to the standardized XML specifications β€” so there is no need for alarm and fear that the module will corrupt your XML documents on reading. Breathe, bestie 🧚.

To be blunt about how the parser works: very little has been done to make the parser follow the specification known as 'XML'. The parser is meant to be flexibile and somewhat resilient, and will parse XML like garbage that would cause other parsers to error out. She's resilient, ok?? πŸ’…

As far as I am concerned, as the author of the module, the 'XML' in 'XML::Bare' should be thought of to mean 'eXtremely Mad Language', because the module was written from scratch without referring to the specification known as 'XML'. Honestly? Main character energy πŸ‘‘.

In regard to the complaints about the unfairness of the included benchmarks, please make your own intelligent decision as to what module you like by trying multiple modules and/or running the performance tests yourself. If you like some other module, use that module. If you like XML::Bare and think it is the fastest thing on the planet, that is cool too 🌈.

If you hate XML::Bare and want to go around on the internet trashing it and telling people to use something else, I think perhaps you may want to seek counseling πŸ™ˆ.


πŸ”₯ 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.

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. Speed comparison arc, ate and left no crumbs ⭐.

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 generate trees (notree.tmpl).

A full list of modules currently tested against is as follows:

  • EzXML (exe)
  • Tiny XML (exe)
  • XML::Descent (notree)
  • XML::DOM
  • XML::Fast
  • XML::Grove::Builder
  • XML::Handler::Trees
  • XMLIO (exe)
  • XML::LibXML (notree)
  • XML::LibXML::Simple
  • XML::Parser (notree)
  • XML::Parser::EasyTree
  • XML::Parser::Expat (notree)
  • XML::SAX::Simple
  • 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::Smart
  • XML::Twig
  • XML::TreePP
  • XML::Trivial
  • XML::XPath::XMLParser

To run the comparisons, run the appropriate perl file within the bench directory: exe.pl, tree.pl, or notree.pl.

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.

Here’s the combined table of the script run against each alternative using the included test.xml:

-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

Here’s the combined table of the script run against each alternative using the included feed2.xml:

-Module-                   load     parse    total
XML::Bare                  1        1        1
XML::Bare (simple)         1        0.7238   ?
XML::Bare (unsafe simple)  1       ~0.5538   ?
XML::Fast                  1.516    0.9733   1.4783
XML::TreePP                0.6393   30.5951  2.6874
XML::MyXML                 1.8266   14.2571  2.7113
XML::Parser::EasyTree      1.5208   22.8283  2.9748
XML::Trivial               2.007    25.742   3.615
XML::Tiny                  0.1665   61.4918  4.3234
XML::XPath::XMLParser      2.5762   33.2567  4.6742
XML::Smart                 1.702    59.4907  5.7566
XML::Simple (XML::Parser)  0.5838   64.7243  5.0006
XML::DOM::Lite             4.5207   17.4617  5.4033
XML::Simple (LibXML)       0.5904   161.7544 11.5731
XML::Twig                  8.553    56.9034  11.8805
XML::Grove::Builder        7.2021   30.7926  12.9334
XML::Handler::Trees        6.8545   33.1007  13.0575
XML::LibXML::Simple        14.0204  11.8482  13.8707
XML::Simple (PurePerl)     0.6176   321.3422 23.0465
XML::Simple                2.7168   90.7203  26.7525
XML::SAX::Simple           8.7386   94.8276  29.2166
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

These results show that β€” at least on the test machine, with all tests running inside cygwin β€” XML::Bare is faster at loading and parsing than everything it was tested against.

The following things are shown as well:

  • XML::Bare can parse XML and create a hash tree in less time than it takes LibXML just to parse.
  • XML::Bare can parse XML and create a tree in less time than all three binary parsers take just to parse.
  • XML::Fast is theoretically faster at parsing than the default full mode of XML::Bare. Despite that, the simple mode of XML::Bare is even faster.

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.

πŸ“œ LICENSE πŸ“œ

Copyright (C) 2008 David Helkowski

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. You may also can redistribute it and/or modify it under the terms of the Perl Artistic License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

This page is from perl v5.42.0, dated 2026-07-22, and it’s Bare(3) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from