We help IT Professionals succeed at work.
Get Started

ASP.NET query a XML file

David C
David C asked
Last Modified: 2012-05-11
Hi Experts I have a XML resultset from Google Maps API from this URL http://maps.googleapis.com/maps/api/geocode/xml?address=Leeds%20Train%20Station&sensor=false Hower I only want to return the address component that has a type of postal_code_prefix and postal_code and the formatted_address Is this possible and how? Please find the code I am currently using. It returns everthing
Const URLString As String = "http://maps.googleapis.com/maps/api/geocode/xml?address=Leeds%20Train%20Station&sensor=false"
        Dim reader As XmlTextReader = New XmlTextReader(URLString)
        Do While (reader.Read())
            Select Case reader.NodeType

                Case XmlNodeType.Element 'Display beginning of element.
                    Response.Write("<" & reader.Name)
                    If reader.HasAttributes Then 'If attributes exist
                        While reader.MoveToNextAttribute()
                            'Display attribute name and value.
                            Response.Write("'{0}'='{1}'", reader.Name, reader.Value)
                        End While
                    End If

                Case XmlNodeType.Text 'Display the text in each element.
                Case XmlNodeType.EndElement 'Display end of element.
            End Select

Open in new window

Watch Question
Project Manager
This problem has been solved!
Unlock 2 Answers and 20 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE