Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2007, 01:16 AM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default String to XML

Hi ,

I need to convert a string to xml and load it into a datagrid. How do i do this? this is my coding..

           strOutput="<Person>John</Person><Item>Pen</Item> _
            <Amount>4</Amount>"


                xdd = New XmlDataDocument
                xdd.LoadXml(strOutput)
                xdd.Save(Server.MapPath("test.xml"))
                xdd.DataSet.ReadXmlSchema(Server.MapPath("test.xml "))
                GridView1.DataSource = xdd.DataSet
                GridView1.DataBind()

xdd.Dataset remain empty and hence i get error in loading datagrid.

How do i solve this? Pls help me.

Thankx in advance,

 
Old April 20th, 2007, 03:48 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Not sure exactly why and how you want to apply your logic, but your code can run alternatively as below too:

string strOutput="<Store><Person>John</Person><Item>Pen</Item><Amount>4</Amount></Store>";
            string Path = Server.MapPath("~/Data/test.xml");

            FileStream fs = new FileStream(Path,FileMode.OpenOrCreate,FileAccess.R eadWrite);

            StreamWriter writer = new StreamWriter(fs);
            writer.Write(strOutput);

            writer.Close();
            fs.Close();

            XmlDataDocument xdd = new XmlDataDocument();
            xdd.DataSet.ReadXmlSchema(Path);

            DataGrid1.DataSource = xdd.DataSet;
            DataGrid1.DataBind();

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.





Similar Threads
Thread Thread Starter Forum Replies Last Post
to treat xml as string anboss XSLT 5 July 13th, 2008 10:45 AM
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 05:51 AM
convert string to xml prafullaborade XML 3 May 21st, 2008 06:56 AM
Text String to XML testsubject Visual Studio 2005 1 November 27th, 2006 06:26 AM
Text String to XML testsubject XML 1 November 26th, 2006 06:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.