Solved

SQL: Loading XML into a table::

Posted on 2013-06-25
3
236 Views
Last Modified: 2013-07-03
hello team,

A third party of ours offered us a download method for an XML file.
Here is the issue; they are giving us the table in pagination. Meaning, page 1, 2, etc

I suppose, I can loop through x number of pages but don't know how to put them into ONE table and of course ONE xml in sql server 2008
Any assistance is appreciated
0
Comment
Question by:John Esraelo
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 500 total points
ID: 39277620
Ummm... Not sure what you mean, or asking for, so will need a bit more explanation.

Are you saying that there are multiple XML files that you want to combine into a single table, or, a single XML file ?

Is it possible to give us an example (changing some labels and obfuscating sensitive data) and what you hope to achieve as a result ?

Sometimes, you might have to first load into a temporary staging area as a transition stage before putting away into your final destination.
0
 

Author Comment

by:John Esraelo
ID: 39278303
It is supposed to be a single table with 10,000 appx records (see URL, softwares.xml).  The keeper of the data does not want to allow users to download the whole table to avoid overload. Therefore, the so called API of theirs is allowing the users to specify a page number.  
http://www.samanage.com/api/index.html
I suppose I can loop thru the X number of pages, insert them as an xml record in a sql table.
At that point I am not sure how to combine all pages together.
0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 39298606
Sorry about that... Didn't get back to you in a timely manner...

The hard bit is knowing how many pages. By the looks of things you can specify how many entries per page, not sure if there is a maximum, so would be interesting to first manually explore the maximum.

It does say that every request will give you the number of entries, the number of pages, etc. as part of the header block. While the example says "tickets" the example results seems to be "hardwares".

So, as a strategy I would write an SQL script to get the first 1 entry, examine that for total number of entries, then loop through grabbing a page at a time (saving as a disk file, use the -o param if using curl), specifying the number of entries per page, import that file into a staging table (a temp table would work), then once all pages have been loaded (or no more results), go through the staging table and then put away.  

Not sure why or when you need to combine the pages, assuming what you really want is the resulting nodes.

I would be breaking up the XML into discrete fields / columns based on the nodes of interest to you. You can always recreate an XML document based on those columns depending on what you ultimately want to do (and what format you need).
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

912 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