Last post Jun 04, 2015 02:01 AM by Li Wang
Jun 02, 2015 07:27 AM|harrison.scott|LINK
I have the following XML which is returned to me from google when I pass in the users location
<formatted_address>Fitzroy VIC 3065, Australia</formatted_address>
I Pass in the city name, which returns me the above, I'm then trying to pull out the postcode i.e 3065 but the code I have picks up the first Long_name which is fitzroy this is what I have
var postCodeElement = result.Element("address_component").Element("long_name");
I need to somehow say where type = postal_code which sadly I'm struggling to do so, can someone give me a hand?
Jun 04, 2015 02:01 AM|Li Wang|LINK
Thank you for your post.
Below is for your reference.
using (TextReader reader = new StringReader(xml))
XDocument document = XDocument.Load(reader);
//get the last address_component elements
string value = document.Root.Elements("address_component").Last().Element("long_name").Value;
Hoping my reply could be helpful to you.