如何一个XmlDocument转换为数组<字节>?数组、转换为、字节、XmlDocument

由网友(討人歡喜)分享简介:我构建了一个的XmlDocument ,现在我想将它转换为数组。如何才能做到这一点?I constructed an XmlDocument and now I want to convert it to an array. How can this be done?谢谢推荐答案请尝试以下操作:using S...

我构建了一个的XmlDocument ,现在我想将它转换为数组。如何才能做到这一点?

I constructed an XmlDocument and now I want to convert it to an array. How can this be done?

谢谢

推荐答案

请尝试以下操作:

using System.Text;
using System.Xml;

XmlDocument dom = GetDocument()
byte[] bytes = Encoding.Default.GetBytes(dom.OuterXml);

如果你想preserve文档的文本编码,那么默认编码切换到所需的编码,或按照Jon飞碟双向的建​​议。

If you want to preserve the text encoding of the document, then change the Default encoding to the desired encoding, or follow Jon Skeet's suggestion.

阅读全文

相关推荐

最新文章