What's the difference between XElement and XDocument?

前端 未结 4 899
鱼传尺愫
鱼传尺愫 2020-12-29 04:09

What is the difference between XElement and XDocument and when do you use each?

4条回答
  •  长情又很酷
    2020-12-29 04:35

    According to the MSDN article LINQ to XML vs. DOM, under the subheading "Working Directly with XML Elements":

    When using LINQ to XML, you use the XDocument class only if you want to add a comment or processing instruction at the root level of the document.

提交回复
热议问题