Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # extract pricedb from gzipped gnucash xml file
  3.  
  4. use strict;
  5. use warnings;
  6. use XML::LibXML;
  7.  
  8. die 'specify gnucash xml file as argument' unless $ARGV[0];
  9. my $doc = XML::LibXML->load_xml(location => $ARGV[0]);
  10.  
  11. if (my $db = $doc->getElementsByTagName('gnc:pricedb')->shift()) {
  12. # add explicit namespace declarations
  13. for my $prefix ('price', 'cmdty', 'ts') {
  14. $db->setNamespace($db->lookupNamespaceURI($prefix), $prefix, 0);
  15. }
  16.  
  17. my $dbdoc = XML::LibXML::Document->new();
  18. $dbdoc->setDocumentElement($db);
  19.  
  20. print $dbdoc->serialize();
  21. }
Add Comment
Please, Sign In to add comment