什么是建立在.NET中的XML文档的最佳方法是什么? [英] What is the best way to build up an XML document in .NET?

查看:101
本文介绍了什么是建立在.NET中的XML文档的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎有很多选择,在创建.NET中的XML文档。什么是最好的方法呢?

There seem to be many options to create an XML document in .NET. What's the best approach?

推荐答案

的XmlWriter有一个漂亮的界面,在流创建文档,只进式的。它的工作原理最好的,如果您有需要映射为XML递归结构。

XmlWriter has a nice interface for creating a document in a streaming, forward-only style. It works best if you have a recursive structure that you need to map into XML.

我只会使用DOM API作为最后的手段。乔恩说,LINQ到XML是另一种方式去。不管你做什么,不过,不回落到字符串格式化,因为有类似的命名空间,实体引用,属性引用等细微之处,你就需要得到正确的。

I would only use the DOM API as a last resort. As Jon says, LINQ to XML is another way to go. Whatever you do, though, don't fall back to string formatting, as there are subtleties like namespaces, entity quoting, attribute quoting, etc. that you'd need to get right.

这篇关于什么是建立在.NET中的XML文档的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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