title: R: harvesting data with rvest fail - because of "nested" forms?
body: <p>For extracting content with "R", there is a new package 'rvest' from Hadley Wickam.
  It works fine for simple sessions, e.g. getting timetables for railway connection. But when I try to us the advanced search, it fails:</p>
  
  <pre><code>url     &lt;- "http://mobile.bahn.de/bin/mobil/query.exe/dox?country=DEU&amp;rt=1&amp;use_realtime_filter=1&amp;webview=&amp;searchMode=NORMAL"
  sitzung &lt;- html_session(url)
  p1.form &lt;- html_form(sitzung)[[1]]
  p2      &lt;- submit_form(sitzung, p1.form, submit='advancedProductMode')
  p2.form &lt;- html_form(p2)[[1]]
  form.mod&lt;- set_values( p2.form
                        ,REQ0JourneyStopsS0G     = "HH"
                        ,REQ0JourneyStopsZ0G     = "F"
                        )
  final   &lt;- submit_form(sitzung, form.mod, submit='start')
  
  Error in vapply(elements, encode, character(1)) : 
    values must be length 1,
   but FUN(X[[18]]) result is length 0
  </code></pre>
  
  <p>Same result with:</p>
  
  <pre><code> submit_form(p2, form.mod, submit='start'9
  </code></pre>
  
  <p>Any ideas? It was successful, if I modify and send form 'p1.form'.
  Content of second form:</p>
  
  <pre><code>&lt;form&gt; '&lt;unnamed&gt;' (POST http://mobile.bahn.de/bin/mobil/query.exe/dox?ld=96240&amp;n=8&amp;i=c6.05923240.1417523354&amp;rt=1&amp;use_realtime_filter=1&amp;webview=&amp;OK#focus)
    &lt;input hidden&gt; 'queryPageDisplayed': yes
    &lt;input hidden&gt; 'REQ0JourneyStopsS0A': 1
    &lt;input text&gt; 'REQ0JourneyStopsS0G':
    &lt;input hidden&gt; 'REQ0JourneyStopsS0ID':
    &lt;input hidden&gt; 'REQ0JourneyStopsZ0A': 1
    &lt;input text&gt; 'REQ0JourneyStopsZ0G':
    &lt;input hidden&gt; 'REQ0JourneyStopsZ0ID':
    &lt;input text&gt; 'REQ0JourneyDate': 02.12.14
    &lt;input text&gt; 'REQ0JourneyTime': 13:40
    &lt;input radio&gt; 'REQ0HafasSearchForw': 1
    &lt;input radio&gt; 'REQ0HafasSearchForw': 0
    &lt;input hidden&gt; 'existProductNahverkehr': yes
    &lt;input checkbox&gt; 'REQ0JourneyProduct_prod_list': 4:0001111111000000
    &lt;input hidden&gt; 'REQ0Tariff_TravellerType.1': E
    &lt;input hidden&gt; 'REQ0Tariff_TravellerReductionClass.1': 0
    &lt;input image&gt; 'start':
    &lt;input hidden&gt; 'REQ0Tariff_Class': 2
    &lt;input submit&gt; 'chgBC=y&amp;getstop': Reiseprofil Ã¤ndern
    &lt;input submit&gt; 'HWAI=QUERY!options=hide!&amp;getstop': Suchoptionen ausblenden
    &lt;input hidden&gt; 'REQ0JourneyStops1.0A': 1
    &lt;input text&gt; 'REQ0JourneyStops1.0G':
    &lt;input hidden&gt; 'REQ0JourneyStops2.0A': 1
    &lt;input text&gt; 'REQ0JourneyStops2.0G':
    &lt;input submit&gt; 'chgProd=y&amp;getstop': Verkehrsmittelwahl Ã¤ndern
    &lt;select&gt; 'REQ0HafasChangeTime' [0/9]
    &lt;input hidden&gt; 'existOptimizePrice': 1
    &lt;input checkbox&gt; 'REQ0HafasOptimize1': 0:1
    &lt;input checkbox&gt; 'REQ0JourneyProduct_opt0': 1
    &lt;input checkbox&gt; 'REQ0JourneyProduct_opt3': 1
    &lt;input hidden&gt; 'existOptionBits': yes
    &lt;input hidden&gt; 'immediateAvail': ON
    &lt;input submit&gt; 'start': Suchen
  </code></pre>