See also the google geolocator and ZIP code lookup demo
This works fine since the response is for a single address element. Regex is obviously going to be a poor choice when an XML document contains multiple elements.
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtAddress.Text.Length > 0) { lblAccuracy.Text = ""; lblResult.Text = ""; StringBuilder sb = new StringBuilder(); sb.Append("http://maps.google.com/maps/geo?q="); sb.Append(Server.UrlEncode(txtAddress.Text)); sb.Append("&output=xml&oe=utf8&sensor=false&key=*** ENTER YOUR GOOGLE API KEY HERE ***"); XDocument responseXML = XDocument.Load(sb.ToString()); string elementZip4 = "PostalCodeNumber"; StringBuilder sbMatch = new StringBuilder(); sbMatch.Append("<"); sbMatch.Append(elementZip4); sbMatch.Append(">.*</"); sbMatch.Append(elementZip4); sbMatch.Append(">"); Match matchZip = Regex.Match(responseXML.ToString(), sbMatch.ToString()); if (matchZip.Success) { // Account for angle brackets in SubString expression lblResult.Text = matchZip.Value.Substring(elementZip4.Length + 2, 5); } Match matchAccuracy = Regex.Match(responseXML.ToString(), "<AddressDetails Accuracy=\"\\d\""); if (matchAccuracy.Success) { Match accVal = Regex.Match(matchAccuracy.Value, "\\d+"); lblAccuracy.Text = "Accuracy = " + accVal.Value; } } }