c# - 如何从字符串转换为 XElement 对象

标签 c# xml xelement

我有这样一个字符串:"<Root><Child>Hey</Child></Root>"

如何将其转换为 XElement对象?

最佳答案

使用XElement.Parse方法如下

XElement xmlTree = XElement.Parse("<Root><Child>Hey</Child></Root>");
Console.WriteLine(xmlTree);

关于c# - 如何从字符串转换为 XElement 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7847424/

相关文章:

c# - 根据 asp.net 中的复选框列表中的选定选项制作相对字符串

sql - 在 t-sql 中使用 .query() 只获取内部文本

xml - XSL 问题 : how can I select a set of nodes based on a set of node values?

c# - 根据 Linq 查询中的属性值过滤掉重复的 XElement

c# - 如何防止 XElement.DescendantNodes() 输出重复的文本值?

c# - 正则表达式前瞻在 .NET 中不起作用

c# - 如何在虚拟现实 (GearVR) 应用程序中打开 URL

C# 分隔 args 参数

xml - 在 Groovy 中加载、修改和编写 XML 文档

c# - XML 中命名空间的区别