Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # extract pricedb from gzipped gnucash xml file
- use strict;
- use warnings;
- use XML::LibXML;
- die 'specify gnucash xml file as argument' unless $ARGV[0];
- my $doc = XML::LibXML->load_xml(location => $ARGV[0]);
- if (my $db = $doc->getElementsByTagName('gnc:pricedb')->shift()) {
- # add explicit namespace declarations
- for my $prefix ('price', 'cmdty', 'ts') {
- $db->setNamespace($db->lookupNamespaceURI($prefix), $prefix, 0);
- }
- my $dbdoc = XML::LibXML::Document->new();
- $dbdoc->setDocumentElement($db);
- print $dbdoc->serialize();
- }
Add Comment
Please, Sign In to add comment