First, install GXML. See the README document in your distribution.
Here's a simple, but typical, example of using GXML:
use GXML; # Create new object my $gxml = new XML::GXML(); # Process a file, return a scalar containing new stuff print $gxml->ProcessFile('my-xml-file.xml');
You can pass parameters to the GXML new() method using a hash. The parameters it takes are:
Here's an example of creating a GXML object with some parameters:
use GXML; my $gxml = new XML::GXML({'templateDir' => '/my/path/to/templates/', 'html' => 'on', 'dashConvert' => 'on'});
You can feed XML data to GXML using a scalar or a file. It can return the processed stuff in either way, too. Here are examples:
use GXML; my $gxml = new XML::GXML(); # Take a scalar, return a scalar my $xml = '<basetag>hi there</basetag>'; my $new = $gxml->Process($xml); # Take a file, return a scalar print $gxml->ProcessFile('my-xml-file.xml'); # Take a file, output to another file $gxml->ProcessFile('source.xml', 'dest.xml');
That's all there is to it! The more advanced API features will be covered later. Now let's go to what the "processing" does, starting with attributes and variables.