Sunday, 21 September 2014

XML to dataset Visual Studio 2010



I'm stuck. I don't use XML much. But, I need to pull some info from a web site, put it in a dataset, do some validations, then add it to a database. Thought this would be pretty straight forward with the dataset.ReadXML function... but it's not... I get one row and one item as a result of my code - server time. I put the ds in a datagridview just to check it, and it shows only the server time. I don't get it... Any help would be appreciated! Here's my code and the xml it should return (checked it with an xmlreader function)



Dim strISBN As String
strISBN = "9780399155161"

Dim strISBNDB As String = "http://ift.tt/1uUhiNO" & strISBN

Dim ds As New DataSet
ds.ReadXml(strISBNDB)

DataGridView1.DataSource = ds.DefaultViewManager


XML:



<ISBNdb server_time="2014-09-21T07:06:24Z">
<BookList total_results="1" page_size="10" page_number="1" shown_results="1">
<BookData book_id="scarpetta" isbn="0399155163" isbn13="9780399155161">
<Title>Scarpetta</Title>
<TitleLong></TitleLong>
<AuthorsText>Patricia Cornwell</AuthorsText>
<PublisherText publisher_id="g_p_putnams_sons">New York : G. P. Putnam's Sons, c2008./PublisherText>
<Subjects>
<Subject subject_id="literature_fiction_contemporary">Literature &amp; Fiction -- Contemporary</Subject>
<Subject subject_id="mystery_thrillers_thrillers">Mystery &amp; Thrillers -- Thrillers</Subject>
<Subject subject_id="scarpetta_kay_fictitious_character_fiction">Scarpetta, Kay (Fictitious character) -- Fiction</Subject>
<Subject subject_id="medical_examiners_law_fiction">Medical examiners (Law) -- Fiction</Subject>
<Subject subject_id="mystery_fiction">Mystery fiction</Subject>
<Subject subject_id="forensic_pathologists_fiction">Forensic pathologists -- Fiction</Subject>
<Subject subject_id="women_physicians_fiction">Women physicians -- Fiction</Subject>
</Subjects>
</BookData>
</BookList>
</ISBNdb>

No comments:

Post a Comment