我使用SAX解析器解析來自http url的XML數據。 我正在創建一個BlackBerry應用程序,它顯示從一個位置到另一個位置的方向數據。在黑莓中解析xml的問題
我的應用程序非常準確地解析了某些位置的數據,但是對於某些位置,它給了我org.xml.sax.SAXParseException:結束標記與開始標記'meta'不匹配。
當我跟蹤我的應用程序,然後我才知道,數據是從HTTP URL來是不正確的,雖然網址中包含正確的XML數據
的XML數據我解析:
<?xml version="1.0" encoding="UTF-8"?>
<DirectionsResponse>
<status>OK</status>
<route>
<summary>I-65 N and AL-14 W</summary>
<leg>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4582500</lat>
<lng>-86.3841000</lng>
</start_location>
<end_location>
<lat>32.4582300</lat>
<lng>-86.3832400</lng>
</end_location>
<polyline>
<points>aobeEr{fnOJyCGQ</points>
<levels>B?B</levels>
</polyline>
<duration>
<value>8</value>
<text>1 min</text>
</duration>
<html_instructions>Head <b>east</b> on <b>Market St</b></html_instructions>
<distance>
<value>81</value>
<text>266 ft</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4582300</lat>
<lng>-86.3832400</lng>
</start_location>
<end_location>
<lat>32.4602500</lat>
<lng>-86.3831700</lng>
</end_location>
<polyline>
<points>}nbeEfvfnOsKM</points>
<levels>BB</levels>
</polyline>
<duration>
<value>25</value>
<text>1 min</text>
</duration>
<html_instructions>Turn <b>left</b> to stay on <b>Market St</b></html_instructions>
<distance>
<value>226</value>
<text>0.1 mi</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4602500</lat>
<lng>-86.3831700</lng>
</start_location>
<end_location>
<lat>32.4603600</lat>
<lng>-86.3870500</lng>
</end_location>
<polyline>
<points>q{beExufnOUfW</points>
<levels>BB</levels>
</polyline>
<duration>
<value>61</value>
<text>1 min</text>
</duration>
<html_instructions>Turn <b>left</b> onto <b>Cobbs Ford Rd/Co Rd 2</b></html_instructions>
<distance>
<value>364</value>
<text>0.2 mi</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4603600</lat>
<lng>-86.3870500</lng>
</start_location>
<end_location>
<lat>32.4865600</lat>
<lng>-86.4070600</lng>
</end_location>
<polyline>
<points>g|beE`ngnOwBfDeExEcCjA{[email protected]`@mVlOoRdN{[email protected]@</points>
<levels>[email protected][email protected]?B</levels>
</polyline>
<duration>
<value>130</value>
<text>2 mins</text>
</duration>
<html_instructions>Slight <b>right</b> to merge onto <b>I-65 N</b> toward <b>Birmingham</b></html_instructions>
<distance>
<value>3478</value>
<text>2.2 mi</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4865600</lat>
<lng>-86.4070600</lng>
</start_location>
<end_location>
<lat>32.4893200</lat>
<lng>-86.4084500</lng>
</end_location>
<polyline>
<points>_`[email protected]</points>
<levels>B??B</levels>
</polyline>
<duration>
<value>27</value>
<text>1 min</text>
</duration>
<html_instructions>Take exit <b>181</b> for <b>AL-14</b> toward <b>Prattville/Wetumpka</b></html_instructions>
<distance>
<value>333</value>
<text>0.2 mi</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4893200</lat>
<lng>-86.4084500</lng>
</start_location>
<end_location>
<lat>32.4823000</lat>
<lng>-86.4286600</lng>
</end_location>
<polyline>
<points>gqheExsknO~PvPpAhAVNJCnDbFjDvGnA`DnAnErA`I^[email protected]</points>
<levels>[email protected][email protected]??B</levels>
</polyline>
<duration>
<value>228</value>
<text>4 mins</text>
</duration>
<html_instructions>Turn <b>left</b> onto <b>AL-14 W</b></html_instructions>
<distance>
<value>2186</value>
<text>1.4 mi</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4823000</lat>
<lng>-86.4286600</lng>
</start_location>
<end_location>
<lat>32.4755400</lat>
<lng>-86.4283300</lng>
</end_location>
<polyline>
<points>[email protected]</points>
<levels>B???B</levels>
</polyline>
<duration>
<value>68</value>
<text>1 min</text>
</duration>
<html_instructions>Turn <b>left</b> onto <b>Jasmine Trail</b></html_instructions>
<distance>
<value>755</value>
<text>0.5 mi</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>32.4755400</lat>
<lng>-86.4283300</lng>
</start_location>
<end_location>
<lat>32.4755400</lat>
<lng>-86.4288500</lng>
</end_location>
<polyline>
<points>c{eeE`ponO?fB</points>
<levels>BB</levels>
</polyline>
<duration>
<value>11</value>
<text>1 min</text>
</duration>
<html_instructions>Turn <b>right</b> onto <b>Windermere Ave</b><div style="font-size:0.9em">Destination will be on the left</div></html_instructions>
<distance>
<value>49</value>
<text>161 ft</text>
</distance>
</step>
<duration>
<value>558</value>
<text>9 mins</text>
</duration>
<distance>
<value>7472</value>
<text>4.6 mi</text>
</distance>
<start_location>
<lat>32.4582500</lat>
<lng>-86.3841000</lng>
</start_location>
<end_location>
<lat>32.4755400</lat>
<lng>-86.4288500</lng>
</end_location>
<start_address>I65 Srv Rd E, Millbrook, AL 36054, USA</start_address>
<end_address>Prattville, AL 36066, USA</end_address>
</leg>
<copyrights>Map data ©2011 Google</copyrights>
<overview_polyline>
<points>aobeEr{fnOJyCGSsKKUfWwBfDeExEcCjA{[email protected]`@uNxIkNjJ{JlH{[email protected]@[email protected]~PvPpAhAVNJCnDbFjDvGnA`DnAnErA`I^[email protected][email protected]?fB</points>
<levels>[email protected]@@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]</levels>
</overview_polyline>
<bounds>
<southwest>
<lat>32.4581900</lat>
<lng>-86.4288500</lng>
</southwest>
<northeast>
<lat>32.4893200</lat>
<lng>-86.3831700</lng>
</northeast>
</bounds>
</route>
</DirectionsResponse>
通常,這類問題會包含導致問題的實際XML文本。沒有它,任何人都很難提供幫助。 – 2011-04-21 03:19:59
主席先生,我添加了XML數據,我試圖解析 – khushi 2011-04-21 08:04:45