This is just a general question, let's say I make an API call to google and google returns an XML document with multiple fields and lines of data. What is the best way to take that data and put it into a dataset?
Here is an example of my API call with control parameters passed into the API call:
Is there a way to filter on specific fields in the XML so it presents correctly? It seems to show just the 2 parent nodes and there is only junk data in there. I see the word "Status" and the data of "OK" and the word "PlaceSearchResponse_Id" and the data
of "0"
What is the best way to take that data and put it into a dataset?
Well……I've seen such cases many times and I've told you it just depends on whether your xml contents can be converted into DataSet/DataTable successfully or not——Not every xml file can be converted into a DataTable/DataSet。
Schwimms
Member
100 Points
327 Posts
Best Way To Create a Dataset From an API Call That Returns XML
Jun 08, 2012 06:41 PM|LINK
This is just a general question, let's say I make an API call to google and google returns an XML document with multiple fields and lines of data. What is the best way to take that data and put it into a dataset?
Here is an example of my API call with control parameters passed into the API call:
("https://maps.googleapis.com/maps/api/place/search/xml?location=" _
& lat & "," & lng & "&radius=5000&keyword=" & Replace(searchvenuenametextbox, " ", "+") _
& "&sensor=false&key=" & googleapikey)
RichardY
Star
8376 Points
1573 Posts
Re: Best Way To Create a Dataset From an API Call That Returns XML
Jun 08, 2012 07:21 PM|LINK
It's been a while but I think you would consume the xml with an XmlReader and them use the DataSet.ReadXml() method. Somthing like this:
XmlReader reader = XmlReader.Create("Url");
DateSet ds = new Dataset();
ds.ReadXml(reader);
Schwimms
Member
100 Points
327 Posts
Re: Best Way To Create a Dataset From an API Call That Returns XML
Jun 08, 2012 07:44 PM|LINK
Is there a way to filter on specific fields in the XML so it presents correctly? It seems to show just the 2 parent nodes and there is only junk data in there. I see the word "Status" and the data of "OK" and the word "PlaceSearchResponse_Id" and the data of "0"
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best Way To Create a Dataset From an API Call That Returns XML
Jun 10, 2012 12:57 AM|LINK
Well……I've seen such cases many times and I've told you it just depends on whether your xml contents can be converted into DataSet/DataTable successfully or not——Not every xml file can be converted into a DataTable/DataSet。
Please refer my post at:http://forums.asp.net/p/1811549/5018019.aspx/1?Re+Fetch+XML+Clean+Up+Add+to+Dataset+in+VB
Reguards!