Topic: Extract only address node from XML

Hi I'm new with OnlineMaps Plugin,

I'm using the latest version (beta), I need to extract only the address from Xml, I get a big data xml:

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>street_address</type>
  <formatted_address>1-5 Bread St, London EC2V 6DL, UK</formatted_address>
  <address_component>
   <long_name>1-5</long_name>
   <short_name>1-5</short_name>
   <type>street_number</type>
  </address_component>
  <address_component>
   <long_name>Bread Street</long_name>
   <short_name>Bread St</short_name>
   <type>route</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>EC2V 6DL</long_name>
   <short_name>EC2V 6DL</short_name>
   <type>postal_code</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5140963</lat>
    <lng>-0.0942200</lng>
   </location>
   <location_type>ROOFTOP</location_type>
   <viewport>
    <southwest>
     <lat>51.5127473</lat>
     <lng>-0.0955690</lng>
    </southwest>
    <northeast>
     <lat>51.5154453</lat>
     <lng>-0.0928710</lng>
    </northeast>
   </viewport>
  </geometry>
  <place_id>ChIJ7XGUpqoEdkgRg0KSOl1scgk</place_id>
  <plus_code>
   <global_code>9C3XGW74+J8</global_code>
   <compound_code>GW74+J8 City of London, London, United Kingdom</compound_code>
  </plus_code>
 </result>
 <result>
  <type>bank</type>
  <type>establishment</type>
  <type>finance</type>
  <type>point_of_interest</type>
  <formatted_address>120 Cheapside, London EC2V 7JB, UK</formatted_address>
  <address_component>
   <long_name>120</long_name>
   <short_name>120</short_name>
   <type>street_number</type>
  </address_component>
  <address_component>
   <long_name>Cheapside</long_name>
   <short_name>Cheapside</short_name>
   <type>route</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>EC2V 7JB</long_name>
   <short_name>EC2V 7JB</short_name>
   <type>postal_code</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5143020</lat>
    <lng>-0.0942421</lng>
   </location>
   <location_type>ROOFTOP</location_type>
   <viewport>
    <southwest>
     <lat>51.5129530</lat>
     <lng>-0.0955911</lng>
    </southwest>
    <northeast>
     <lat>51.5156510</lat>
     <lng>-0.0928931</lng>
    </northeast>
   </viewport>
  </geometry>
  <place_id>ChIJW2CGpaoEdkgR_1JWfabQtAo</place_id>
  <plus_code>
   <global_code>9C3XGW74+P8</global_code>
   <compound_code>GW74+P8 City of London, London, United Kingdom</compound_code>
  </plus_code>
 </result>
 <result>
  <type>street_address</type>
  <formatted_address>1 Bread St, London EC2V 6DL, UK</formatted_address>
  <address_component>
   <long_name>1</long_name>
   <short_name>1</short_name>
   <type>street_number</type>
  </address_component>
  <address_component>
   <long_name>Bread Street</long_name>
   <short_name>Bread St</short_name>
   <type>route</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>EC2V 6DL</long_name>
   <short_name>EC2V 6DL</short_name>
   <type>postal_code</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5141344</lat>
    <lng>-0.0944659</lng>
   </location>
   <location_type>RANGE_INTERPOLATED</location_type>
   <viewport>
    <southwest>
     <lat>51.5127854</lat>
     <lng>-0.0958149</lng>
    </southwest>
    <northeast>
     <lat>51.5154834</lat>
     <lng>-0.0931169</lng>
    </northeast>
   </viewport>
  </geometry>
  <place_id>Eh8xIEJyZWFkIFN0LCBMb25kb24gRUMyViA2REwsIFVLIhoSGAoUChIJ7deIpKoEdkgRwQrQChHVKyIQAQ</place_id>
 </result>
 <result>
  <type>route</type>
  <formatted_address>120 Cheapside, London EC2V 6DL, UK</formatted_address>
  <address_component>
   <long_name>120</long_name>
   <short_name>120</short_name>
   <type>street_number</type>
  </address_component>
  <address_component>
   <long_name>Cheapside</long_name>
   <short_name>Cheapside</short_name>
   <type>route</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>EC2V 6DL</long_name>
   <short_name>EC2V 6DL</short_name>
   <type>postal_code</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5141590</lat>
    <lng>-0.0943204</lng>
   </location>
   <location_type>GEOMETRIC_CENTER</location_type>
   <viewport>
    <southwest>
     <lat>51.5128100</lat>
     <lng>-0.0956694</lng>
    </southwest>
    <northeast>
     <lat>51.5155079</lat>
     <lng>-0.0929714</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>51.5141395</lat>
     <lng>-0.0944483</lng>
    </southwest>
    <northeast>
     <lat>51.5141784</lat>
     <lng>-0.0941925</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJYS8tpKoEdkgRUJPJQLFH5Tc</place_id>
 </result>
 <result>
  <type>postal_code</type>
  <formatted_address>Wood St, London EC2V 6DL, UK</formatted_address>
  <address_component>
   <long_name>EC2V 6DL</long_name>
   <short_name>EC2V 6DL</short_name>
   <type>postal_code</type>
  </address_component>
  <address_component>
   <long_name>Wood Street</long_name>
   <short_name>Wood St</short_name>
   <type>route</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5145302</lat>
    <lng>-0.0948453</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>51.5132124</lat>
     <lng>-0.0958390</lng>
    </southwest>
    <northeast>
     <lat>51.5159103</lat>
     <lng>-0.0931410</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>51.5139548</lat>
     <lng>-0.0950376</lng>
    </southwest>
    <northeast>
     <lat>51.5151679</lat>
     <lng>-0.0939424</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJOVVTsKoEdkgRSsbLlWYU_LY</place_id>
 </result>
 <result>
  <type>postal_code</type>
  <type>postal_code_prefix</type>
  <formatted_address>London EC2V, UK</formatted_address>
  <address_component>
   <long_name>EC2V</long_name>
   <short_name>EC2V</short_name>
   <type>postal_code</type>
   <type>postal_code_prefix</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5156290</lat>
    <lng>-0.0917305</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>51.5136734</lat>
     <lng>-0.0961054</lng>
    </southwest>
    <northeast>
     <lat>51.5176903</lat>
     <lng>-0.0884922</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>51.5136734</lat>
     <lng>-0.0961054</lng>
    </southwest>
    <northeast>
     <lat>51.5176903</lat>
     <lng>-0.0884922</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJC47nGVUDdkgRs7jlYHnaC8A</place_id>
 </result>
 <result>
  <type>administrative_area_level_3</type>
  <type>political</type>
  <formatted_address>City of London, UK</formatted_address>
  <address_component>
   <long_name>City of London</long_name>
   <short_name>City of London</short_name>
   <type>administrative_area_level_3</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5123443</lat>
    <lng>-0.0909852</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>51.5068695</lat>
     <lng>-0.1138210</lng>
    </southwest>
    <northeast>
     <lat>51.5233212</lat>
     <lng>-0.0727492</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>51.5068695</lat>
     <lng>-0.1138210</lng>
    </southwest>
    <northeast>
     <lat>51.5233212</lat>
     <lng>-0.0727492</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJ4Y3fTlUDdkgR0Gbsoi2uDgQ</place_id>
 </result>
 <result>
  <type>locality</type>
  <type>political</type>
  <type>sublocality</type>
  <type>sublocality_level_1</type>
  <formatted_address>City of London, London, UK</formatted_address>
  <address_component>
   <long_name>City of London</long_name>
   <short_name>City of London</short_name>
   <type>locality</type>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_1</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5123443</lat>
    <lng>-0.0909852</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>51.5067659</lat>
     <lng>-0.1138210</lng>
    </southwest>
    <northeast>
     <lat>51.5233212</lat>
     <lng>-0.0727492</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>51.5067659</lat>
     <lng>-0.1138210</lng>
    </southwest>
    <northeast>
     <lat>51.5233212</lat>
     <lng>-0.0727492</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJX4XfTlUDdkgRwISR0ciFEQo</place_id>
 </result>
 <result>
  <type>locality</type>
  <type>political</type>
  <formatted_address>London, UK</formatted_address>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5073509</lat>
    <lng>-0.1277583</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>51.3849401</lat>
     <lng>-0.3514683</lng>
    </southwest>
    <northeast>
     <lat>51.6723432</lat>
     <lng>0.1482710</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>51.3849401</lat>
     <lng>-0.3514683</lng>
    </southwest>
    <northeast>
     <lat>51.6723432</lat>
     <lng>0.1482710</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJdd4hrwug2EcRmSrV3Vo6llI</place_id>
 </result>
 <result>
  <type>postal_town</type>
  <formatted_address>London, UK</formatted_address>
  <address_component>
   <long_name>London</long_name>
   <short_name>London</short_name>
   <type>postal_town</type>
  </address_component>
  <address_component>
   <long_name>Greater London</long_name>
   <short_name>Greater London</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>England</long_name>
   <short_name>England</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United Kingdom</long_name>
   <short_name>GB</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>51.5569879</l<message truncated>

I only want to get/extract the formatted_address, please help me with this!
Thanks in advance!

Re: Extract only address node from XML

Hello.

Way 1:

string formatted_address = OnlineMapsXML.Load(s)["result"]["formatted_address"].Value();

Way 2:

string formatted_address = OnlineMapsXML.Load(s).Find<string>("result/formatted_address");

Way 3:

OnlineMapsGoogleGeocodingResult[] results = OnlineMapsGoogleGeocoding.GetResults(s);
string formatted_address = results[0].formatted_address;
Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Extract only address node from XML

Thanks a lot Alex for quick support, keep up the good job with OnlineMaps wink

Re: Extract only address node from XML

Hi Alex,

I have another question for you how can I go directly to a marker position not to go smoothly via Update method likein your examples, to load instant location of the marker?