Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Dataset to defined XML schema

Dataset to defined XML schema

Scheduled Pinned Locked Moved C#
databasexmlhelptutorialquestion
20 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Yosh_

    I've had no answers. I wouldn't be posting here if I had an answer to this. Pls can u help me out?

    He who goes for revenge must first dig two graves.

    P Offline
    P Offline
    Pete OHanlon
    wrote on last edited by
    #4

    That's not the way the site works. This is a volunteer site where people help out as and when they can. If you post a question in multiple locations, then answers to the question become fragmented making it harder for us to identify what's been said to you already, and making it next to impossible for somebody following a link in from a search engine to follow answers to a problem that they may be having just because you're impatient.

    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

    My blog | My articles | MoXAML PowerToys | Onyx

    Y 1 Reply Last reply
    0
    • P Pete OHanlon

      That's not the way the site works. This is a volunteer site where people help out as and when they can. If you post a question in multiple locations, then answers to the question become fragmented making it harder for us to identify what's been said to you already, and making it next to impossible for somebody following a link in from a search engine to follow answers to a problem that they may be having just because you're impatient.

      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

      My blog | My articles | MoXAML PowerToys | Onyx

      Y Offline
      Y Offline
      Yosh_
      wrote on last edited by
      #5

      But i have posted this nowhere else. Of course i know how the site works!

      He who goes for revenge must first dig two graves.

      P 1 Reply Last reply
      0
      • Y Yosh_

        But i have posted this nowhere else. Of course i know how the site works!

        He who goes for revenge must first dig two graves.

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #6

        You've posted it in two places. Q and A, and here. The two aren't linked together.

        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

        My blog | My articles | MoXAML PowerToys | Onyx

        Y 1 Reply Last reply
        0
        • P Pete OHanlon

          You've posted it in two places. Q and A, and here. The two aren't linked together.

          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

          My blog | My articles | MoXAML PowerToys | Onyx

          Y Offline
          Y Offline
          Yosh_
          wrote on last edited by
          #7

          Pete, i went over to Q&A, and that wasn't me. Besides, the questions are quite different. He's trying to export to an XML file, while i'm trying to export data to a Typed XML Schema file. I can do the former, but have problems with the latter. I've seen the responses to that, and they aren't helpful to mine. I humbly ask, pls is there any1 with a solution to my problem?

          He who goes for revenge must first dig two graves.

          P 1 Reply Last reply
          0
          • Y Yosh_

            Pete, i went over to Q&A, and that wasn't me. Besides, the questions are quite different. He's trying to export to an XML file, while i'm trying to export data to a Typed XML Schema file. I can do the former, but have problems with the latter. I've seen the responses to that, and they aren't helpful to mine. I humbly ask, pls is there any1 with a solution to my problem?

            He who goes for revenge must first dig two graves.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #8

            My apologies then.

            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

            My blog | My articles | MoXAML PowerToys | Onyx

            Y 1 Reply Last reply
            0
            • Y Yosh_

              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.

              R Offline
              R Offline
              Rob Philpott
              wrote on last edited by
              #9

              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.

              Y 1 Reply Last reply
              0
              • P Pete OHanlon

                My apologies then.

                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

                My blog | My articles | MoXAML PowerToys | Onyx

                Y Offline
                Y Offline
                Yosh_
                wrote on last edited by
                #10

                No problem, Pete, just a misconception.

                He who goes for revenge must first dig two graves.

                1 Reply Last reply
                0
                • R Rob Philpott

                  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.

                  Y Offline
                  Y Offline
                  Yosh_
                  wrote on last edited by
                  #11

                  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.

                  R P 2 Replies Last reply
                  0
                  • Y Yosh_

                    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.

                    R Offline
                    R Offline
                    Rob Philpott
                    wrote on last edited by
                    #12

                    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.

                    Y 1 Reply Last reply
                    0
                    • Y Yosh_

                      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.

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #13

                      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

                      My blog | My articles | MoXAML PowerToys | Onyx

                      Y 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        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

                        My blog | My articles | MoXAML PowerToys | Onyx

                        Y Offline
                        Y Offline
                        Yosh_
                        wrote on last edited by
                        #14

                        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.

                        P 1 Reply Last reply
                        0
                        • R Rob Philpott

                          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.

                          Y Offline
                          Y Offline
                          Yosh_
                          wrote on last edited by
                          #15

                          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.

                          1 Reply Last reply
                          0
                          • Y Yosh_

                            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.

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #16

                            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

                            My blog | My articles | MoXAML PowerToys | Onyx

                            Y 1 Reply Last reply
                            0
                            • Y Yosh_

                              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.

                              P Offline
                              P Offline
                              Pravin Patil Mumbai
                              wrote on last edited by
                              #17

                              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.

                              Y 1 Reply Last reply
                              0
                              • P Pete OHanlon

                                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

                                My blog | My articles | MoXAML PowerToys | Onyx

                                Y Offline
                                Y Offline
                                Yosh_
                                wrote on last edited by
                                #18

                                Cumbersome. We've got little time for pilot mode so i guess i'll try it. Thanx a lot.

                                He who goes for revenge must first dig two graves.

                                1 Reply Last reply
                                0
                                • P Pravin Patil Mumbai

                                  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.

                                  Y Offline
                                  Y Offline
                                  Yosh_
                                  wrote on last edited by
                                  #19

                                  Thanx a lot. I think LINQ will help us achieve it.

                                  He who goes for revenge must first dig two graves.

                                  1 Reply Last reply
                                  0
                                  • Y Yosh_

                                    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.

                                    K Offline
                                    K Offline
                                    kevinnicol
                                    wrote on last edited by
                                    #20

                                    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();
                                    
                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups