diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-09-12 20:31:29 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-09-12 20:31:29 +0200 |
commit | 07d8ef6646413fc2a8585f9ae64ca75f55764bd7 (patch) | |
tree | 892cf10b09958ebb37b8c2a8a7fe0682f10e2dc2 | |
parent | f79f32d5295e2d7ada7c03a1669d4b3deac95f18 (diff) |
add NVV (with fugly fixups for broken XML-ish data)
-rw-r--r-- | lib/Travel/Status/DE/HAFAS.pm | 23 |
1 files changed, 19 insertions, 4 deletions
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 . '</wrap>'; + 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} ) { |