|
|
2010-02-10
, 09:26
|
|
Posts: 1 |
Thanked: 0 times |
Joined on Feb 2010
|
#2
|
Code:$twig->parsefile("$fn");
Code:my $sender = $item->first_child_text('sender') || "";
Code:unless((!$sender && !$receiver) || ($text =~ /\n/))
|
|
2010-02-10
, 12:18
|
|
Posts: 5 |
Thanked: 0 times |
Joined on Nov 2009
|
#3
|
|
|
2010-02-16
, 00:29
|
|
Posts: 5 |
Thanked: 0 times |
Joined on Nov 2009
|
#4
|
So I made a conventionscript to convert SMS that i exported from Windows mobile via Jeyo mobile companion and to be able to import them with rmoravciks smstools
The script depends on the Perl-module XML::Twig (libxml-twig-perl in Debian)
So the way to do this is something like:
I hope that this helps someone!
#!/usr/bin/perl use XML::Twig; my $fn = $ARGV[0]; my $twig = XML::Twig->new(twig_handlers => { item => \&itemhandler }); $twig->parsefile("$fn"); sub itemhandler { my $t = shift; my $item = shift; my $sender = $item->first_child_text('sender') || ""; my $receiver = $item->first_child_text('receiver') || ""; my $date = $item->first_child_text('delivertime'); my $text = $item->first_child_text('subject'); # if sender is set -> there was a sender -> it was sent to us my $type = $sender ? "deliver" : "submit"; if($sender =~ /(\+\d+)/) { $sender = $1; } if($receiver =~ /\<(\+?\d+)/) { $receiver = $1; } $date =~ s/\-/\./g; $date =~ s/\:\d\d$//; unless((!$sender && !$receiver) || ($text =~ /\n/)) { print qq!sms|$type|! . ($type eq "deliver" ? qq!"$sender"|""! : qq!""|"$receiver"!) . qq!|""|"$date"|""|"$text"!; print "\n"; } }