---
title: "Difference between XElement and XDocument"  
description: "Difference between XElement and XDocument"  
author: "Anonymous User"  
published: 2011-07-26  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/1122/difference-between-xelement-and-xdocument  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Difference between XElement and XDocument

Both are the classes defined by System.Xml.Linq namespace \
\
XElement class represents an XML fragment \
XDocument class represents an entire XML document with all associated meta-data.\

## Answers

### Answer by Anonymous User

Both are the classes defined by System.Xml.Linq namespace \
\
XElement class represents an XML fragment \
XDocument class represents an entire XML document with all associated meta-data.\


---

Original Source: https://www.mindstick.com/interview/1122/difference-between-xelement-and-xdocument

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
