---
title: "How do we access attributes using “XmlReader”?"  
description: "How do we access attributes using “XmlReader”?"  
author: "Vijay Shukla"  
published: 2013-04-02  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/1705/how-do-we-access-attributes-using-xmlreader  
category: "xml"  
tags: ["xml"]  
reading_time: 1 minute  

---

# How do we access attributes using “XmlReader”?

The XmlReader class provides various methods and properties for reading attributes. Attributes are most commonly found on elements. However, they are also allowed on XML declaration and document type nodes.

When positioned on an element node, the MoveToAttribute methods enable you to go through the attribute list of the element. After MoveToAttribute has been called, the node properties—such as Name, NamespaceURI, Prefix, and so on—reflect the properties of that attribute, and not the containing element it belongs to.

## Answers

### Answer by Vijay Shukla

The XmlReader class provides various methods and properties for reading attributes. Attributes are most commonly found on elements. However, they are also allowed on XML declaration and document type nodes.

When positioned on an element node, the MoveToAttribute methods enable you to go through the attribute list of the element. After MoveToAttribute has been called, the node properties—such as Name, NamespaceURI, Prefix, and so on—reflect the properties of that attribute, and not the containing element it belongs to.


---

Original Source: https://www.mindstick.com/interview/1705/how-do-we-access-attributes-using-xmlreader

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
