sql server - Read XML Schema and Data in .NET -
i'm using sql server , vb.net. in sql i'm using following:
select top 1 * tablename 1=0 xml auto, type, xmlschema
to schema tablename. use
select * tablename id=1 xml, auto, type, elements xsinil, root('xml')
to data row i'm interested.
if use following code in vb:
private ds new dataset ds.readxmlschema("xmlschema.txt")
i end ds containing 1 table correctly defined set of columns
if try:
ds.readxml("xmldata.txt")
the code succeeds, don't have rows in table of dataset.
my question is, need in order read xml data created sql server datatable schema specified sql server.
you need include
xmlschema
clause in second (data) query first (schema) query. if don't data output missing namespace , won't conform schema.you need specify target namespace schema qualifying
xmlschema
directive (e.g.xmlschema('http://tempuri.org')
). if don't sql server generate namespace in each query, , may not match.you need make sure column lists ,
for xml
clauses of 2 queries same. in example you've gotxsinil
specified in data query not in schema query.
so here need specify schema query
select top 1 * tablename 1=0 xml auto, type, elements xsinil, root('xml'), xmlschema('http://tempuri.org')
and data query
select * tablename xml auto, type, elements xsinil, root('xml'), xmlschema('http://tempuri.org')
Comments
Post a Comment