I wrote:
Has anybody here written one or more Perl scripts using XML::LibXML to
find replace in XML documents?...
Thank you the all the replies. One person recommending a Perl module
called XML::Twig. Another person recommended I use regular expressions.
Two people recommended the use of XSLT. One of these provided sample
code. The other wrote a full-blown program! (Thanks, Andrew
Houghton!)
In the end I re-read some of my Perl/XML books and decided to write a
SAX filter using XML::SAX::ParserFactory. Such a filter has the
following shape:
use strict;
use XML::SAX::ParserFactory;
my $handler = MyHandler-new();
my $parser = XML::SAX::ParserFactory-parser(Handler = $handler);
$parser-parse_uri($ARGV[0]);
exit;
package MyHandler;
sub new {
my $type = shift;
return bless {}, $type;
}
sub start_element {
my ($self, $element) = @_;
print Starting element $element-{Name}\n;
}
sub end_element {
my ($self, $element) = @_;
print Ending element $element-{Name}\n;
}
sub characters {
my ($self, $characters) = @_;
print characters: $characters-{Data}\n;
}
1;
I have saved my script at the following location:
http://infomotions.com/musings/getting-started/fix-ead.txt
The script will eventually be a part of a workshop I am giving called
Shining a LAMP on XML. the outline, to date, is here:
http://infomotions.com/musings/getting-started/LAMP.txt
'More later.
--
Eric Lease Morgan