recieving XML data from another system

Posted on 2005-05-11
Last Modified: 2010-04-07
I have a web form that I have created where I need to recieve data from a remote server. the server is being sent to me as XML data through a URL that I have. How do I send a request on page load for this data and then store the recieved XML data as a dataset or usable data on my web form? I have never done this before and have no idea how to begin.
Question by:NickMalloy
    LVL 7

    Expert Comment

    is this an xml web service you are using?

    the dataset has a readxml you can use.

    Dim ds as dataset
    ds = new dataset

    ds.readxml("path to xml as string or xml stream")

    That will make a table representation of the xml structure.  The DS will contain 1 to many tables that you can use just as you would any other datatable or dataset.  So you could bind the datatebles to datagrids or gridviews depending on your version of the framework.

    Author Comment

    The person I am working with told me.  You can think of it as an XML web service – its doing the function like a XML web service would
    LVL 7

    Accepted Solution

    so you can do something like this with a web service

            Dim dr As DataRow
            Dim dt As New DataTable
            Dim nodeChild As XmlNode
            Dim xdoc As New XmlDocument
            Dim MemberElem As XmlElement

       'PreAuthenticate the WebService
            Dim MyWebObj As WS.ClientInterviewWeb = New WS.WSCLass
            MyWebObj.PreAuthenticate() = True
            MyWebObj.Credentials = System.Net.CredentialCache.DefaultCredentials

               'call your function that returns XML.  This code calls a web method and passes it a param of 43

                'Create the DataTable layout
                dt.Columns.Add(New DataColumn("MemberID", GetType(String)))
                dt.Columns.Add(New DataColumn("SSN", GetType(String)))
                dt.Columns.Add(New DataColumn("FirstName", GetType(String)))
                dt.Columns.Add(New DataColumn("LastName", GetType(String)))
                dt.Columns.Add(New DataColumn("MaidenName", GetType(String)))
                dt.Columns.Add(New DataColumn("BirthDate", GetType(String)))

                'parse the xml into a datatable.  This uses an XML structure that looks like this <xmlrow MEMBERID="1"  SSN="222-22-2222" FIRSTNAME="Joe" LASTNAME="Doe" MAIDENNAME="" />  
                'This is case sensitive.
                For Each nodeChild In xdoc.FirstChild.ChildNodes

                    dr = dt.NewRow

                    dr(0) = nodeChild.Attributes("MEMBERID").Value.ToString
                    dr(1) = nodeChild.Attributes("SSN").Value.ToString
                    dr(2) = nodeChild.Attributes("FIRSTNAME").Value.ToString
                    dr(3) = nodeChild.Attributes("LASTNAME").Value.ToString
                    dr(4) = nodeChild.Attributes("MAIDENNAME").Value.ToString
                    dr(5) = nodeChild.Attributes("BIRTHDATE").Value.ToString



            Catch ex As Exception
                   throw ex
            End Try

            Return dt

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now