From 07d8ef6646413fc2a8585f9ae64ca75f55764bd7 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 12 Sep 2015 20:31:29 +0200 Subject: add NVV (with fugly fixups for broken XML-ish data) --- lib/Travel/Status/DE/HAFAS.pm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm index 896edca..d96c7de 100644 --- a/lib/Travel/Status/DE/HAFAS.pm +++ b/lib/Travel/Status/DE/HAFAS.pm @@ -31,6 +31,12 @@ my %hafas_instance = ( name => 'Nahverkehrsservice Sachsen-Anhalt', productbits => [qw[ice ice regio regio regio tram bus ondemand]], }, + NVV => { + url => 'http://auskunft.nvv.de/auskunft/bin/jp/stboard.exe', + name => 'Nordhessischer VerkehrsVerbund', + productbits => + [qw[ice ic_ec regio s u tram bus bus ferry ondemand regio regio]], + }, ); sub new { @@ -92,16 +98,25 @@ sub new { . $reply->content . ''; + if ( defined $service and $service eq 'NVV' ) { + + # Returns invalid XML with tags inside HIMMessage's lead attribute. + # Fix this. + # Also, I couldn't get this to work with + # $ref->{raw_xml} =~ s{ ( lead = " [^"]+? ) < [^>]* > }{$1}xg; + # and am probably missing some essential caveat here. + # Working patches are very welcome. + while ( $ref->{raw_xml} =~ m{ lead = " [^"]+ < }x ) { + $ref->{raw_xml} =~ s{ ( lead = " [^"]+ ) < [^>]* > }{$1}x; + } + } + if ( $ref->{developer_mode} ) { say $ref->{raw_xml}; } $ref->{tree} = XML::LibXML->load_xml( string => $ref->{raw_xml}, - - # recover => 2, - # suppress_errors => 1, - # suppress_warnings => 1, ); if ( $ref->{developer_mode} ) { -- cgit v1.2.3