Dataset to defined XML schema
-
Do you wish to create the schema as part of the xml production or is that defined already? Without going near code, SQL Server has got various things in it to retrieve data in XML, using the FOR XML AUTO thing for instance. That is of course, presuming you're using SQL Server.
Regards, Rob Philpott.
Rob, Yes, i'm using SQL Server. The problem is that i'm supposed to pull several data from various tables, and the schema has been defined by my clients in one cumbersome XML schema file. The data includes names, addresses, sales agents (which could be multiple), contacts (phones and emails, which could also be multiple), and so on. So i'm supposed to bring all data relating to one person into an XML file. That's my problem.
He who goes for revenge must first dig two graves.
-
Rob, Yes, i'm using SQL Server. The problem is that i'm supposed to pull several data from various tables, and the schema has been defined by my clients in one cumbersome XML schema file. The data includes names, addresses, sales agents (which could be multiple), contacts (phones and emails, which could also be multiple), and so on. So i'm supposed to bring all data relating to one person into an XML file. That's my problem.
He who goes for revenge must first dig two graves.
Well, that could be a tricky thing to do depending on how the schema has been laid out. Probably the best approach is to see if you can use the FOR XML AUTO thing with appropriate joins to get your query response to validate against the schema, but then apart from that you might want to look at the XSD tool which could generate business objects from the schema which you'll have to populate manually through code.
Regards, Rob Philpott.
-
Rob, Yes, i'm using SQL Server. The problem is that i'm supposed to pull several data from various tables, and the schema has been defined by my clients in one cumbersome XML schema file. The data includes names, addresses, sales agents (which could be multiple), contacts (phones and emails, which could also be multiple), and so on. So i'm supposed to bring all data relating to one person into an XML file. That's my problem.
He who goes for revenge must first dig two graves.
Ouch. Your choices are either to serialize your different objects out to a temporary location and then use Xslt to convert them, or you create a super class that contains the values and serialize that. If I were you, I'd go with the Xslt approach.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
Ouch. Your choices are either to serialize your different objects out to a temporary location and then use Xslt to convert them, or you create a super class that contains the values and serialize that. If I were you, I'd go with the Xslt approach.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
Ouch. Harder than i thought.
Pete O'Hanlon wrote:
Your choices are either to serialize your different objects out to a temporary location and then use Xslt to convert them
i'm sorry, how do i do this? U mean i should write the data into an xml file, then manually use the xsl tool to conform it?
He who goes for revenge must first dig two graves.
-
Well, that could be a tricky thing to do depending on how the schema has been laid out. Probably the best approach is to see if you can use the FOR XML AUTO thing with appropriate joins to get your query response to validate against the schema, but then apart from that you might want to look at the XSD tool which could generate business objects from the schema which you'll have to populate manually through code.
Regards, Rob Philpott.
Rob Philpott wrote:
but then apart from that you might want to look at the XSD tool which could generate business objects from the schema which you'll have to populate manually through code.
I'm sorry i don't know about this.
He who goes for revenge must first dig two graves.
-
Ouch. Harder than i thought.
Pete O'Hanlon wrote:
Your choices are either to serialize your different objects out to a temporary location and then use Xslt to convert them
i'm sorry, how do i do this? U mean i should write the data into an xml file, then manually use the xsl tool to conform it?
He who goes for revenge must first dig two graves.
Write to several XML files and then use XSL to form it into one.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
Hi guys, i have a project in which I'm supposed to retrieve data from the database and put d data into an XML file (with a defined schema), and send that file encrypted and all. My problem, however, is getting the data into XML. Please anyone knows how to achieve this?
He who goes for revenge must first dig two graves.
I think you can go for Linq for XML. It is very flexible, easy to use for handling XML files. You can find some good links : 1. LINQ to XML[^] 2. http://msdn.microsoft.com/en-us/library/bb387098.aspx[^] 3. http://msdn.microsoft.com/en-us/library/bb308960.aspx[^] 4. http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx[^] Hope this helps. All the best.
-
Write to several XML files and then use XSL to form it into one.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
I think you can go for Linq for XML. It is very flexible, easy to use for handling XML files. You can find some good links : 1. LINQ to XML[^] 2. http://msdn.microsoft.com/en-us/library/bb387098.aspx[^] 3. http://msdn.microsoft.com/en-us/library/bb308960.aspx[^] 4. http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx[^] Hope this helps. All the best.
-
Hi guys, i have a project in which I'm supposed to retrieve data from the database and put d data into an XML file (with a defined schema), and send that file encrypted and all. My problem, however, is getting the data into XML. Please anyone knows how to achieve this?
He who goes for revenge must first dig two graves.
I have done similar things before using an sql data adapter. This produces a seperate file for xml schema though. I'm not sure if this is what your looking for.
SqlCommand cmd = new SqlCommand(); cmd.Connection = new SqlConnection(@"cnnstring"); cmd.Connection.Open(); cmd.CommandText = "SELECT \* FROM Table1; SELECT \* FROM Table2"; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); ds.WriteXmlSchema(@"C:\\dat.xsd"); ds.WriteXml(@"C:\\dat.xml"); cmd.Connection.Close();