Connecting Tech Pros Worldwide Forums | Help | Site Map

get fields from an xml schema

Newbie
 
Join Date: Sep 2008
Posts: 3
#1: Mar 1 '09
How can I get read the fields from an XML schema in C# to be able to use them to create and SQL Server database?

Moderator
 
Join Date: Mar 2006
Posts: 1,103
#2: Mar 2 '09

re: get fields from an xml schema


There's at least 2 questions there:

1. How to read XML?
Suggest using either a XMLDocument approach (DOM), or a SAX approach. With the Document approach, you load the entire xml into a document and query the nodes you want to find by means of xpath, or parent-child relations between the nodes.

With the SAX approach, you read the document as a stream, loading the fields as you need it.

2. Create a SQL Server DB from XML information.
Unless you have a flat xml, or one that is prestructured in some given way, you will need to define how your xml maps to the tables. Short answer, you need to know a specific format of your schema for it to work.

Do you have keys and keyrefs in your xml schema?
Newbie
 
Join Date: Sep 2008
Posts: 3
#3: Mar 2 '09

re: get fields from an xml schema


Thanks for the reply.

I don't have any keys in the schema. I created it from one table in Access.

I actually worked out a way to get the fields by reading the xml file into a dataset and then getting the column captions. This helps me for the field names, but I would also like to able to read the types, lengths and other information if possible.
Reply