是否有一个的XElement相当于XmlWriter.WriteRaw? [英] Is there an XElement equivalent to XmlWriter.WriteRaw?

查看:163
本文介绍了是否有一个的XElement相当于XmlWriter.WriteRaw?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将目前使用的一些code的的XmlWriter 来创建一个文件,而不是返回的XElement 的内容。

I'm converting some code that currently uses an XmlWriter to create a document to instead return an XElement of the content.

到目前为止,我很享受在构建code在模仿文档的结构方式,但被使用书面内容 XmlWriter.WriteRaw 以避免重新xmlizing的XML。我找不到在 System.Xml.Linq的命名空间的任何等价物。做一件存在吗?

So far, I'm enjoying structuring the code in a way that mimics the structure of the document, but there is content that was written using XmlWriter.WriteRaw to avoid re-xmlizing the xml. I can't find any equivalent in the System.Xml.Linq namespace. Does one exist?

推荐答案

XElement.Parse() 应该做的伎俩。

XElement.Parse() should do the trick.

例如:

XElement e = new XElement("root",
    new XElement("child",
        XElement.Parse("<big><blob><of><xml></xml></of></blob></big>"),
        new XElement("moreXml")));

这篇关于是否有一个的XElement相当于XmlWriter.WriteRaw?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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