【问题标题】:Show XML content in div innertext在 div 内部文本中显示 XML 内容
【发布时间】:2014-11-20 05:28:11
【问题描述】:

我的 XML 是一个字符串,需要在 div 中显示 我已经搜索了格式化 XML 的所有方法,但它不起作用,因为我最终将我的内容绑定到了一个 div。

以下是我在我的 asp.net 应用程序 c# 代码中使用的内容。

request = //my xml string     
XDocument doc = XDocument.Parse(request);
divLogResults.InnerText = doc.ToString()

这里列出的所有方法我都试过了

What is the simplest way to get indented XML with line breaks from XmlDocument?

所以这不是重复的。我怎样才能以简单的方式做到这一点?

【问题讨论】:

    标签: c# html asp.net xml


    【解决方案1】:

    在文本区域中绑定您的 XML 内容。我认为这应该可行。

    网络表单:

       <textarea rows="20" cols="40" style="border:none;" runat="server" id="txtXML" readonly="true">
        </textarea>
    

    后面的代码:

    request = // xml string     
    XDocument doc = XDocument.Parse(request);
    txtXML.Text = doc.ToString()
    

    请确保您的 xml 内容附加了标题 例如,

    <?xml version="1.0" encoding="ISO-8859-1"?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多