-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevernote-parse
executable file
·33 lines (25 loc) · 977 Bytes
/
evernote-parse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl
use strict;
use XML::Twig;
my $xml_infile = shift or die("You must supply an xml input file!\n Usage: xml-cleaner infile outfile");
die("$xml_infile is not a readable xml file!") unless (-f $xml_infile && !-b $xml_infile);
my $xml_outfile = shift or die("You must supply an output file name!\n Usage: xml-cleaner infile outfile");
my $twig = XML::Twig->new(
pretty_print => 'indented',
discard_spaces => 1,
empty_tags=> 'normal',
comments=> 'keep',
);
# Instead of tabs, use 4 spaces, ie - soft tabs.
$twig->set_indent(" ");
$twig->safe_parsefile($xml_infile);
my $root = $twig->root;
my $en_export = $root->first_child( 'en-export' );
my $note = $en_export->first_child('note');
my $title = $note->first_child('title');
#open OUT,">$xml_outfile" or die("Failed to open $xml_outfile for write.");
#print OUT qq|<?xml version="1.0"?>\n|;
#$twig->print(\*OUT);
#close OUT;
print $title->text;
exit;