Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frnds i need to load an xml file into an textbox(multilne) including all the tags and everything contained in that folder...Here is my code its just read only the single value can any 1 pls Do me a favour to solve dis prob....

My xml file
XML
<?xml version="1.0" encoding="utf-8" ?>
<catalog>
  <book id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
    <description>
      An in-depth look at creating applications
      with XML.
    </description>
  </book>
  ...............


and my asp in c# code..

C#
protected void Button2_Click(object sender, EventArgs e)
    {
        string s=FileUpload1.FileName.ToString();



        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath(s));

        Int32 i = increment();
        DataTable dt = ds.Tables[0];
        if (i <= dt.Rows.Count)
        {
            DataRow dr;
            dr = dt.Rows[i - 1];
            TextBox2.Text=dr[0].ToString();
            
        }
      
    }

    private int increment()
    {
        string strInput = Hidint;
        int incrValue = Convert.ToInt32(strInput);
        incrValue += 1;
        Hidint = incrValue.ToString();
        return incrValue;
    }


Thank You...
Posted
Comments
[no name] 22-Jul-13 6:52am    
TextBox2.Text += dr[0].ToString();
usha C 22-Jul-13 6:54am    
Am getting the same result sir i need to read all the values including xml tags....
usha C 22-Jul-13 7:42am    
Hey thanks lot it works...u r really awesome gave me answer in single line of code i was trying to work with this in hard logical codes thanks lot...
ridoy 22-Jul-13 7:49am    
ok,glad to help you.I updated the comment as an answer.Accept it,as it will help others who will face same problem in future.
Member 11538223 8-Apr-15 2:38am    
Hidint has not been mentioned . what is that?

1 solution

You can use richtextbox instead of textbox?
Or,
Alternatively try..
C#
TextBox1.Text = File.ReadAllText(filePath);//path your xml file
 
Share this answer
 
v2
Comments
usha C 22-Jul-13 8:06am    
Sir richtextbox tool will not b available in Asp
ridoy 22-Jul-13 8:08am    
so,second option is for you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900