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. Web Development
  3. ASP.NET
  4. How do I populate a DataSet from a XML string?

How do I populate a DataSet from a XML string?

Scheduled Pinned Locked Moved ASP.NET
questionxmlhelp
9 Posts 3 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.
  • J Offline
    J Offline
    janani13
    wrote on last edited by
    #1

    HI, I am having a string which is in xml format. i want to populate a dataset using the string. I used the following code . But it doesnt convert.Please help me.

    stream = new StringReader(XMLdoc.ToString());
    Text = new XmlTextReader(stream);
    dsXml.ReadXml(Text);

    N S 2 Replies Last reply
    0
    • J janani13

      HI, I am having a string which is in xml format. i want to populate a dataset using the string. I used the following code . But it doesnt convert.Please help me.

      stream = new StringReader(XMLdoc.ToString());
      Text = new XmlTextReader(stream);
      dsXml.ReadXml(Text);

      N Offline
      N Offline
      Nigel Ferrissey
      wrote on last edited by
      #2

      You might want to have a look at the dataSet.ReadXml() method. http://msdn.microsoft.com/en-us/library/system.data.dataset.readxml(VS.71).aspx[^] Hope that helps.

      1 Reply Last reply
      0
      • J janani13

        HI, I am having a string which is in xml format. i want to populate a dataset using the string. I used the following code . But it doesnt convert.Please help me.

        stream = new StringReader(XMLdoc.ToString());
        Text = new XmlTextReader(stream);
        dsXml.ReadXml(Text);

        S Offline
        S Offline
        sashidhar
        wrote on last edited by
        #3

        anu_anu wrote:

        stream = new StringReader(XMLdoc.ToString());

        where is the xml doc present..! try this..!:cool:

        ds.ReadXml ("YourFilePath in Server.mapath.xml);

        MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

        J 1 Reply Last reply
        0
        • S sashidhar

          anu_anu wrote:

          stream = new StringReader(XMLdoc.ToString());

          where is the xml doc present..! try this..!:cool:

          ds.ReadXml ("YourFilePath in Server.mapath.xml);

          MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

          J Offline
          J Offline
          janani13
          wrote on last edited by
          #4

          Hi, I just have the XML code in XMLdoc as string format.I dont have any xml file.

          StreamReader reader = new StreamReader(response.GetResponseStream());

                  string str = reader.ReadLine();
                  while (str != null)
                  {
                   
                      XMLdoc = XMLdoc + str;
                      Console.WriteLine(str);
                      str = reader.ReadLine();
                  }
          
          S 1 Reply Last reply
          0
          • J janani13

            Hi, I just have the XML code in XMLdoc as string format.I dont have any xml file.

            StreamReader reader = new StreamReader(response.GetResponseStream());

                    string str = reader.ReadLine();
                    while (str != null)
                    {
                     
                        XMLdoc = XMLdoc + str;
                        Console.WriteLine(str);
                        str = reader.ReadLine();
                    }
            
            S Offline
            S Offline
            sashidhar
            wrote on last edited by
            #5

            anu_anu wrote:

            StreamReader reader = new StreamReader(response.GetResponseStream());

            string str = reader.ReadLine(); Check The above str reading any document in the form of xml by keeping a break point may tht the reason..!

            MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

            J 1 Reply Last reply
            0
            • S sashidhar

              anu_anu wrote:

              StreamReader reader = new StreamReader(response.GetResponseStream());

              string str = reader.ReadLine(); Check The above str reading any document in the form of xml by keeping a break point may tht the reason..!

              MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

              J Offline
              J Offline
              janani13
              wrote on last edited by
              #6

              Sorry i cant get you.

              S 1 Reply Last reply
              0
              • J janani13

                Sorry i cant get you.

                S Offline
                S Offline
                sashidhar
                wrote on last edited by
                #7

                Check the response stream, and keep a break point on the bolded text ,extract the string str, .and check the string format.Is it coming in the form of XML. if it is comming..! use ReadtoEnd metod

                HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                using (StreamReader sr =
                new StreamReader(objResponse.GetResponseStream()))
                {
                result = sr.ReadToEnd();

                              // Close and clean up the StreamReader
                        sr.Close();
                    }
                

                MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

                J 1 Reply Last reply
                0
                • S sashidhar

                  Check the response stream, and keep a break point on the bolded text ,extract the string str, .and check the string format.Is it coming in the form of XML. if it is comming..! use ReadtoEnd metod

                  HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                  using (StreamReader sr =
                  new StreamReader(objResponse.GetResponseStream()))
                  {
                  result = sr.ReadToEnd();

                                // Close and clean up the StreamReader
                          sr.Close();
                      }
                  

                  MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

                  J Offline
                  J Offline
                  janani13
                  wrote on last edited by
                  #8

                  Ya.. It is in the xml format.Is it possible to assign the xml string into a new xml file.

                  S 1 Reply Last reply
                  0
                  • J janani13

                    Ya.. It is in the xml format.Is it possible to assign the xml string into a new xml file.

                    S Offline
                    S Offline
                    sashidhar
                    wrote on last edited by
                    #9

                    Then Try this below link It May Help Post XML Data to an ASP.NET Page using C#[^]

                    MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

                    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