什么是xelement.load和xdocument.load之间的区别? [英] What's the difference between xelement.load and xdocument.load?

查看:118
本文介绍了什么是xelement.load和xdocument.load之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如上所述,什么是XElement.Load和XDocument.Load之间的区别?他们似乎都加载XML文件。

As stated above, what's the difference between XElement.Load and XDocument.Load? They seemingly both load an XML files.

推荐答案

不同的是,一个的XElement 类型表示XML片段,而的XDocument 类型代表了所有相关的元数据的整个XML文档。

The difference is that an XElement type represents an XML fragment while the XDocument type represents an entire XML document with all associated meta-data.

也就是说然而说,对于大多数简单的情况下,您可以互换使用。

That being said however, for most simple cases you can use them interchangeably.

要了解的细微差别在这两个类型之间,并在该信息查询,我会建议你请阅读的Querying一个XDocument与查询一个的XElement

It is important to understand the subtle differences in querying between these two types and for more information on that I would recommend that you please read Querying an XDocument vs. Querying an XElement:

当您通过加载
XDocument.Load 的文档,你会发现,你必须编写查询

略有不同当您通过 XElement.Load
负载。​​

When you load a document via XDocument.Load, you will notice that you have to write queries slightly differently than when you load via XElement.Load.

这篇关于什么是xelement.load和xdocument.load之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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