c# - 如何使用 WebBrowser 控件显示 XML?

标签 c# xml winforms

我有一个包含 xmlstring。我想用它设置 WebBrowser 控件的值并显示为 xml

我可以使用 browser.DocumentText 设置值,但是如何让它显示为 XML?

最佳答案

为@PaoloFalabella 建议的第一个解决方案提供一些代码(即将字符串内容写入临时 xml 文件并导航到它):

//create a random temporary file with an .xml file extension
var path = Path.GetTempPath();
var fileName = Guid.NewGuid().ToString() + ".xml";
var fullFileName = Path.Combine(path, fileName);
//write the contents of your xml string to the temporary file we just created
File.WriteAllText(fullFileName, xmlText); //xmlText is your xml string
//"navigate" to the file
webBrowser.Navigate(fullFileName); //webBrowser is your WebBrowser control

关于c# - 如何使用 WebBrowser 控件显示 XML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5157545/

相关文章:

c# - VideoCamera 获得支持的分辨率

C# BackGroundWorker 与 ProgressBar 流程完成后更新

java - JDOMParseException : Error on line -1: Premature end of file

php - 在 PHP 中将关联数组转换为 XML

android - 设计 View 中底部导航的实时 View 不显示图标和菜单资源

c# - 在C#中发送cmd命令并读取结果

javascript - 现在的 ASP.NET Javascript 框架

c# - 本地和远程运行相同应用程序的不同结果 - Windows 应用程序

c# - 无法更改数据网格文本对齐方式(devexpress 网格控件)

C# 字符串测量