---
title: "how to retrieve attributes using LINQ"  
description: "how to retrieve attributes using LINQ"  
author: "Anonymous User"  
published: 2013-12-09  
updated: 2013-12-10  
canonical: https://www.mindstick.com/forum/1755/how-to-retrieve-attributes-using-linq  
category: "xml"  
tags: ["xml"]  
reading_time: 1 minute  

---

# how to retrieve attributes using LINQ

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to get ALL [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) from "[server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over)" below:

This is the [XML file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php)([partial](https://www.mindstick.com/blog/78/partial-class-in-dot-net)):

```
<?xml version="1.0" encoding="utf-8" standalone="yes"?><server xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="udsServerInfo.xsd" id="57672acc-4ba7-4876-811a-1629eca853ed" productPath="C:\Tools\UDS\udsServerInfo\" osActivated="true">  <networkAdapters>Here is the code which returns NULL for "server":    var server = (from node in doc.Attributes("server")                       select node);
```

I am able to get all networkAdapters by calling doc.Descendants("networkAdapter") but haven't figured out how to obtain the attributes .

Thank you

## Replies

### Reply by Anonymous User

Hi Ashish,\

Try this (assuming doc is an XDocument):

```
var attributes =doc.Descendants("server").Attributes();orvar id =doc.Descendants("server").Attributes("id");orvar productPath =doc.Descendants("server").Attributes("productPath");
```


---

Original Source: https://www.mindstick.com/forum/1755/how-to-retrieve-attributes-using-linq

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
