Can an XML output be generated from a webpage using web::scraper in Perl? Here is an example of HTML taken from a URL:
> <table class="reference">
> <tr>
> <th width="23%" align="left">Property</th>
> <th width="71%" align="left">Description</th>
> <th style="text-align:center;">DOM</th>
> </tr>
> <tr>
// more HTML code
The Perl code snippet used to scrape this data is as follows:
#!/usr/bin/perl
use warnings;
use strict;
use URI;
use Web::Scraper;
my $urlToScrape = "http://www.w3schools.com/jsref/dom_obj_node.asp";
my $rennersdata = scraper {
process "table.reference > tr > td > a", 'renners[]' => 'TEXT';
// more processing code
};
my $res = $teamsdata->scrape(URI->new($urlToScrape));
// more code-snippet
The current output obtained is structured like this:
<PropertyList>
<Property>
<Name>attributes</Name>
// more output
<ReturnValue>
Returns a collection of a node's attributes
</ReturnValue>
....
Desired output format:
<PropertyList>
<Property>
<Name>attributes</Name>
<ReturnValue>Returns a collection of a node's attributes</ReturnValue>
<DOMVersion>1</DOMVersion>
</Property>
</PropertyList>
Please suggest how the for loops can be combined to achieve the desired output structure.
Thank you!