在文本框中加载XML文件 [英] Loading XML File in Textbox

查看:72
本文介绍了在文本框中加载XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨frnds我需要将一个xml文件加载到一个文本框(multilne)中,包括所有标签和该文件夹中包含的所有内容......这是我的代码,它只读取单个值可以任意1个帮我一个忙解决问题......



我的xml文件

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 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>
  ...............





和我的asp in c#code ..





and my asp in c# code..

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...

推荐答案

您可以使用 richtextbox 代替文本框

或者,

或者尝试。 。

You can use richtextbox instead of textbox?
Or,
Alternatively try..
TextBox1.Text = File.ReadAllText(filePath);//path your xml file


这篇关于在文本框中加载XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆