How flexible I can create xml from a dataset?

  • Thread starter Thread starter davidw
  • Start date Start date
D

davidw

In my current solution, I create xml in dll by checking the returned rows
from sql, for example, I will get xml like this

<i><name>test</name><age>10</age></i>
from
select fieldtag=1,name='test',age=10

or

<field name="age">10</field>
from
select xml_??='<field name="age">10</field>'

what I did is creating xml of my standard from different data from sql
server. From recently reading, I found dataset is a suggest solution to
pass data around in dll, so I am trying to figure out a way to store data
from my sql server to a dataset and get the desired xml from it when it is
need. I think my questions are:

1, Does my solution look reasonable?
2, How could I get the xml match my xml schema?

Thanks!
 
Hi David,

A dataset can be represented by (or be) an XML file.
Therefore is not every XML file a dataset.
By instance a XML document can have complex elements, a on SQL based
database cannot.
Therefore you are limited with your XML dataset file to the posibilities of
a SQL database.

But it is very easy to make from a dataset a XML file in streaming mode.
Just dataset.writeXML("path") and you have your dataset, when you want to
add the schema also you can add that as option write the schema also.

I hope this helps,

Cor
 
Thanks for reply.

I know you can specify a schema when you get xml from a dataset, I read some
articles about that. But I could not figure out how to create some special
xml as I want. Say this another way, in sql server, you can use for xml
explicit to create xml from a query. Could I do the similar thing to
datatables in dataset? just simple transformation like set one field as tag
another field as attribute and maybe the third as xml text. Any idea?
 
Hi David,
just simple transformation like set one field as tag
another field as attribute and maybe the third as xml text. Any idea?

My idea is that you cannot

Cor
 
Back
Top