Membuat XML Tree dari Rute Google Maps

Contoh Kasus:

Saya mencari rute dari Sindang Barang Bogor ke Stasiun KA Bogor dengan URL seperti berikut ini:

http://maps.googleapis.com/maps/api/directions/xml?origin=-6.594485,%20106.790634&destination=-6.562095,%20106.734571&sensor=false&units=metric&mode=driving

URL diatas akan menghasilkan halaman yang berisi tulisan xml, kamu bisa tuliskan URL diatas pada browsermu atau lihat pada bagian lampiran terbawah halaman ini.

Permintaan:

Saya ingin membuat XML tree-nya dari hasil tulisan xml diatas.

Pertanyaan:

Bagaimana membuatnya … ?

Jawaban:

Kamu bisa gunakan xml tree yang saya buat seperti dibawah ini:

Lampiran hasil XML dari URL

<?xml version=”1.0″ encoding=”UTF-8″?>
<DirectionsResponse>
<status>OK</status>
<route>
<summary>Jl. Raya Cibungbulang-Bogor</summary>
<leg>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5945396</lat>
<lng>106.7910597</lng>
</start_location>
<end_location>
<lat>-6.5906907</lat>
<lng>106.7918629</lng>
</end_location>
<polyline>
<points>z~fg@csxjSeFi@kC_@iC[wB]mC[</points>
</polyline>
<duration>
<value>70</value>
<text>1 min</text>
</duration>
<html_instructions>Head &lt;b&gt;north&lt;/b&gt; on &lt;b&gt;Jl. Nyi Raja Permas&lt;/b&gt; toward &lt;b&gt; 

Jl. Moh. A. Salamun&lt;/b&gt;

</html_instructions>
<distance>
<value>437</value>
<text>0.4 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5906907</lat>
<lng>106.7918629</lng>
</start_location>
<end_location>
<lat>-6.5903040</lat>
<lng>106.7877653</lng>
</end_location>
<polyline>
<points>xffg@cxxjS?NC^Aj@APAJ?PCdB?DObBOtACXK`CE`CI`B</points>
</polyline>
<duration>
<value>56</value>
<text>1 min</text>
</duration>
<html_instructions>Turn &lt;b&gt;left&lt;/b&gt; onto &lt;b&gt;Jl. Moh. A. Salamun&lt;/b&gt;</html_instructions>
<distance>
<value>455</value>
<text>0.5 km</text>
</distance>
<maneuver>turn-left</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5903040</lat>
<lng>106.7877653</lng>
</start_location>
<end_location>
<lat>-6.5953923</lat>
<lng>106.7884763</lng>
</end_location>
<polyline>
<points>jdfg@q~wjSB@`B?pDC@?xB?Z?|@Bd@?J?d@Cr@Gv@MpGoBPAb@C</points>
</polyline>
<duration>
<value>62</value>
<text>1 min</text>
</duration>
<html_instructions>Turn &lt;b&gt;left&lt;/b&gt; onto &lt;b&gt;Jl. Merdeka&lt;/b&gt;</html_instructions>
<distance>
<value>579</value>
<text>0.6 km</text>
</distance>
<maneuver>turn-left</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5953923</lat>
<lng>106.7884763</lng>
</start_location>
<end_location>
<lat>-6.5955855</lat>
<lng>106.7882661</lng>
</end_location>
<polyline>
<points>ddgg@_cxjSPJFFLT</points>
</polyline>
<duration>
<value>6</value>
<text>1 min</text>
</duration>
<html_instructions>Slight &lt;b&gt;right&lt;/b&gt; to stay on &lt;b&gt;Jl. Merdeka&lt;/b&gt;</html_instructions>
<distance>
<value>32</value>
<text>32 m</text>
</distance>
<maneuver>turn-slight-right</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5955855</lat>
<lng>106.7882661</lng>
</start_location>
<end_location>
<lat>-6.5955780</lat>
<lng>106.7873671</lng>
</end_location>
<polyline>
<points>legg@uaxjSAn@CbA@j@@R</points>
</polyline>
<duration>
<value>42</value>
<text>1 min</text>
</duration>
<html_instructions>Slight &lt;b&gt;right&lt;/b&gt; onto &lt;b&gt;Jl. Kapten Muslihat&lt;/b&gt;</html_instructions>
<distance>
<value>99</value>
<text>0.1 km</text>
</distance>
<maneuver>turn-slight-right</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5955780</lat>
<lng>106.7873671</lng>
</start_location>
<end_location>
<lat>-6.5945330</lat>
<lng>106.7830266</lng>
</end_location>
<polyline>
<points>jegg@a|wjSCnA?^?n@?TCVEbAEjBKfBAP[lBCFGVM\O`@O\_@t@WZa@l@</points>
</polyline>
<duration>
<value>25</value>
<text>1 min</text>
</duration>
<html_instructions>Continue onto &lt;b&gt;Jl. Veteran&lt;/b&gt;</html_instructions>
<distance>
<value>505</value>
<text>0.5 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5945330</lat>
<lng>106.7830266</lng>
</start_location>
<end_location>
<lat>-6.5961850</lat>
<lng>106.7795880</lng>
</end_location>
<polyline>
<points>x~fg@}`wjSCDGLEHCNAH?F?D@D@BFFPPPNLPZV`BxALJ@@t@r@d@d@LL`@d@Zf@FRBHB\C^KbAGb

@Ih@

</points>
</polyline>
<duration>
<value>28</value>
<text>1 min</text>
</duration>
<html_instructions>Continue onto &lt;b&gt;Jl. Gn. Batu/Jl. Raya Cibungbulang-Bogor&lt;/b&gt;</html_instructions>
<distance>
<value>473</value>
<text>0.5 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5961850</lat>
<lng>106.7795880</lng>
</start_location>
<end_location>
<lat>-6.5905514</lat>
<lng>106.7745113</lng>
</end_location>
<polyline>
<points>bigg@mkvjSa@p@u@h@o@f@eBxAq@n@c@b@OLIHMJSNSPCB]VQLKJUPGDk@f@EDq@n@}@t@UPIHG

DA@CB_At@MLC@q@l@{ArAa@\]TgA~@{@x@

</points>
</polyline>
<duration>
<value>80</value>
<text>1 min</text>
</duration>
<html_instructions>&lt;b&gt;Jl. Gn. Batu/Jl. Raya Cibungbulang-Bogor&lt;/b&gt; turns slightly &lt;b&gt;right&lt;/b&gt; and becomes &lt;b&gt;Jl. May Jen Ishak Djuarsa&lt;/b&gt; (signs for &lt;b&gt;JalanNasional11/Dramaga/Jasinga&lt;/b&gt;)</html_instructions>
<distance>
<value>842</value>
<text>0.8 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5905514</lat>
<lng>106.7745113</lng>
</start_location>
<end_location>
<lat>-6.5849226</lat>
<lng>106.7710528</lng>
</end_location>
<polyline>
<points>|efg@ukujSYRWV]Z[X}ArAA@oBdBKHCBMJo@f@KH]XSNUTIFQPMJKHOHKFGBE@C?C@C?S@C?O@[?U

@cA@]@M@A?YBUDOBWDUF]LIBGBMFEBSL_@TC@{AfAIF

</points>
</polyline>
<duration>
<value>39</value>
<text>1 min</text>
</duration>
<html_instructions>Continue onto &lt;b&gt;Jl. Gn. Batu/Jl. Raya Cibungbulang-Bogor&lt;/b&gt;&lt;div style=&quot;font-size:0.9em&quot;&gt;Continue to follow Jl. Raya Cibungbulang-Bogor&lt;/div&gt;</html_instructions>
<distance>
<value>757</value>
<text>0.8 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5849226</lat>
<lng>106.7710528</lng>
</start_location>
<end_location>
<lat>-6.5765312</lat>
<lng>106.7545133</lng>
</end_location>
<polyline>
<points>vbeg@avtjSSLu@h@UTc@ZqAjAyApAu@l@]\sAjAu@p@YRYRm@^kAp@gBv@EBw@`@a@\QVGNCFGd@@L@b@?JBZFjAH`BJpBFbB@l@@`CC\GVQp@CHkAfEe@jA]dAWn@c@~@EJqAvC}AhDk@lAgA|Bs@zAUd@Wh@Wf@CDg@lACDiAdCMb@]tAA`@BV^lB

?R

</points>
</polyline>
<duration>
<value>113</value>
<text>2 mins</text>
</duration>
<html_instructions>Continue onto &lt;b&gt;Jl. Sindang Barang&lt;/b&gt;</html_instructions>
<distance>
<value>2193</value>
<text>2.2 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5765312</lat>
<lng>106.7545133</lng>
</start_location>
<end_location>
<lat>-6.5735606</lat>
<lng>106.7514396</lng>
</end_location>
<polyline>
<points>hncg@unqjS?JMn@Mt@?BQr@I\ENIPCBGJMNA@_@Xa@TKF_Aj@o@`@oHrE</points>
</polyline>
<duration>
<value>27</value>
<text>1 min</text>
</duration>
<html_instructions>Continue onto &lt;b&gt;Jl. Ibrahim Adjie&lt;/b&gt; (signs for &lt;b&gt;Dramaga/Ciampea&lt;/b&gt;)</html_instructions>
<distance>
<value>495</value>
<text>0.5 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5735606</lat>
<lng>106.7514396</lng>
</start_location>
<end_location>
<lat>-6.5723637</lat>
<lng>106.7496434</lng>
</end_location>
<polyline>
<points>v{bg@o{pjSOHa@t@w@tAsAdCSd@QVKL</points>
</polyline>
<duration>
<value>27</value>
<text>1 min</text>
</duration>
<html_instructions>&lt;b&gt;Jl. Ibrahim Adjie&lt;/b&gt; turns slightly &lt;b&gt;left&lt;/b&gt; and becomes &lt;b&gt;Jl. Raya Cibadak-Ciampea/Jl. Raya Cibungbulang-Bogor/Jl. Raya Dramaga&lt;/b&gt;</html_instructions>
<distance>
<value>240</value>
<text>0.2 km</text>
</distance>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5723637</lat>
<lng>106.7496434</lng>
</start_location>
<end_location>
<lat>-6.5654073</lat>
<lng>106.7353136</lng>
</end_location>
<polyline>
<points>ftbg@gppjS?D?B?B?BADEJANCJAX?R?NDPBNRjBh@pDJn@D\Fh@@^@P?N?@?JAN?TCrA?d@AbAIhF?h

@ALAxA?bAAz@?NAZEZCPETO`Ag@dCi@dCELGLINGNA@ILGHKJKHOHSF[J_@LkAXGBOF_GnDcCvA_@TkC~Ag

@Xu@d@[RQNKJk@j@q@r@UTIJSR_A~@_BzAm@n@

</points>
</polyline>
<duration>
<value>144</value>
<text>2 mins</text>
</duration>
<html_instructions>Slight &lt;b&gt;left&lt;/b&gt; onto &lt;b&gt;Jl. Raya Cibadak-Ciampea/Jl. Raya Cibungbulang-Bogor/Jl. Raya Dramaga/Jl. Raya Leuwiliang-Bogor&lt;/b&gt;&lt;div style=&quot;font-size:0.9em&quot;&gt;Continue to follow Jl. Raya Cibadak-Ciampea/Jl. Raya Cibungbulang-Bogor/Jl. Raya Leuwiliang-Bogor&lt;/div&gt;</html_instructions>
<distance>
<value>1976</value>
<text>2.0 km</text>
</distance>
<maneuver>turn-slight-left</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5654073</lat>
<lng>106.7353136</lng>
</start_location>
<end_location>
<lat>-6.5626126</lat>
<lng>106.7351518</lng>
</end_location>
<polyline>
<points>xhag@uvmjSW?O@Y@[?m@?E?]CMAk@?aCJ_@BcDP</points>
</polyline>
<duration>
<value>54</value>
<text>1 min</text>
</duration>
<html_instructions>Slight &lt;b&gt;right&lt;/b&gt;</html_instructions>
<distance>
<value>312</value>
<text>0.3 km</text>
</distance>
<maneuver>turn-slight-right</maneuver>
</step>
<step>
<travel_mode>DRIVING</travel_mode>
<start_location>
<lat>-6.5626126</lat>
<lng>106.7351518</lng>
</start_location>
<end_location>
<lat>-6.5623229</lat>
<lng>106.7342243</lng>
</end_location>
<polyline>
<points>hw`g@uumjSBd@Dx@?N?H?FADEDGFOJMHUL</points>
</polyline>
<duration>
<value>23</value>
<text>1 min</text>
</duration>
<html_instructions>Turn &lt;b&gt;left&lt;/b&gt;&lt;div style=&quot;font-size:0.9em&quot;&gt;Destination will be on the right&lt;/div&gt;</html_instructions>
<distance>
<value>121</value>
<text>0.1 km</text>
</distance>
<maneuver>turn-left</maneuver>
</step>
<duration>
<value>796</value>
<text>13 mins</text>
</duration>
<distance>
<value>9516</value>
<text>9.5 km</text>
</distance>
<start_location>
<lat>-6.5945396</lat>
<lng>106.7910597</lng>
</start_location>
<end_location>
<lat>-6.5623229</lat>
<lng>106.7342243</lng>
</end_location>
<start_address>Jalan Nyi Raja Permas No.1, Bogor Tengah, Bogor, Jawa Barat 16124, Indonesia</start_address>
<end_address>Jalan Sindang Barang No.56, Dramaga, Bogor, Jawa Barat 16680, Indonesia</end_address>
</leg>
<copyrights>Map data ©2015 Google</copyrights>
<overview_polyline>
<points>z~fg@csxjSeFi@kC_@aGy@mC[?NEjAGtCc@xEQbGI`BxGAtC?bBBp@Cr@Gv@MpGoBPAb@CPJT\ErBB~

@CnBC|AKnDMxB_@tBUt@_@~@w@pAs@jAEf@BHXX^`@|BpBjBfBn@r@Zf@FRFf@ObBQlAa@p@u@h@uC`CuAr

Ag@b@iA|@{@p@aDrCmB|AcA|@}BpBeBtAkC`C{BnBmC~BmBzA_Az@o@^QBcABeCFaALWDs@Te@RsClB]TkA~

@uBfBoC~BqBhBoAdAgAr@kAp@gBv@}@d@a@\QVKVEr@LvCTrEHpC@`CC\YhAoApEcApCsCrGeGpMiA|Bk@rAiAdCMb@]tAA`@b@dC?^[dBa@dBMTUZoAx@oLjHyAjCgBjD]d@?HGXEZAl@\|CbAhHBbAQxMCtEAjAGv@aAnFo@rCQ\[h@WTc@PgCr@WJcKfGiGtDm@b@w@v@eBhB_DzCm@n@W?i@BiA?c@Cy@AaDNcDPBd@DhA?PGJWRc@V

</points>
</overview_polyline>
<bounds>
<southwest>
<lat>-6.5963500</lat>
<lng>106.7342243</lng>
</southwest>
<northeast>
<lat>-6.5623229</lat>
<lng>106.7918629</lng>
</northeast>
</bounds>
</route>
</DirectionsResponse>

Sekian dan terima kasih.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *