【问题标题】:how to read xml file into richtextbox?如何将xml文件读入richtextbox?
【发布时间】:2016-04-19 09:32:22
【问题描述】:

我的文本格式为 xml,我想要一个 RichTextBox 像浏览器一样显示它 - 没有任何标记。

我尝试创建新的 XDocument...、XmlRead、XmlReadMode,但似乎没有任何效果。

假设我的文字是这样的:

<heading>


    <line> line the first </line> 
       <line> line the second </line>

</heading>

我希望我的 Richtextbox 显示如下:

line the firs line the second 

我正在使用 System.Xml 和 System.Linq,我应该添加/尝试什么?

【问题讨论】:

  • “我应该添加/尝试什么?” 添加到什么?请发布您目前拥有的 LINQ-to-XML 代码,然后我们可以建议添加或更改的内容。谢谢

标签: c# xml winforms richtextbox


【解决方案1】:

哦,伙计,这很简单:

var xml = XElement.Load("test.xml");
richTextBox.Text = xml.Value;

你有没有尝试过?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 2012-02-24
    • 1970-01-01
    • 2023-03-08
    • 2020-08-27
    • 2011-03-19
    相关资源
    最近更新 更多