title: How to handle XML response data of a Web-Service in JavaScript using JSON
body: <p>I am a newbie to handle XML response data. I have a web service which checks the user and his password in SQL server database and return the response accordingly. Code as follows for the web service method;</p>
  
  <pre><code>&lt;WebMethod()&gt; _
      Public Function Authentication(ByVal username As String, ByVal password As String) As String
  
          'Public Function ConnectToSQL() As String
          Dim con As New SqlConnection
          Dim result As Boolean
          Dim response As String
  
          Try
  
              con.ConnectionString = "Data Source=TestServer;Initial Catalog=MyDB;Persist Security Info=True;User ID=myuser;Password=mypass"
              Dim cmd As New SqlCommand("SELECT username FROM user_detail WHERE username='" + username  + "' AND password='" + password + "'", con)
              con.Open()
  
  
              ' Execute Query
              Dim reader As SqlDataReader = cmd.ExecuteReader()
              result = reader.HasRows
          'Validate user info from database 
             If result = True Then
              response = "Valid user info..Thanks"
          Else
              response = " Not valid user info..Please Enter again, Thanks"
          End If
  
          If Not reader Is Nothing Then
              reader.Close()
              End If
  
          Catch ex As Exception
              MessageBox.Show("Error while connecting to SQL Server." &amp; ex.Message)
          Finally
              con.Close() 'Whether there is error or not. Close the connection.
          End Try
          Return response 
      End Function
  End Class
  </code></pre>
  
  <p>The response is in XML data as shown in following fig.(if entered valid user info)</p>
  
  <p><img src="https://i.stack.imgur.com/91Egr.png" alt="Valid Response"></p>
  
  <p>Now I want to make a view in Javascript, which take input from user and then validate user infor from database via this web service. Can some one help me how to do it?</p>