---
title: "Read xml as a string"  
description: "Read xml as a string"  
author: "Anonymous User"  
published: 2014-01-27  
updated: 2014-01-27  
canonical: https://www.mindstick.com/forum/1887/read-xml-as-a-string  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Read xml as a string

I have an [xml file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php) which i need to read and [store](https://www.mindstick.com/articles/13125/tips-to-increase-sales-of-your-woocommerce-store) it as a string.

Below is my [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand) in xml.

```
<list><SlideShow id="12523" languageadded="sv" publish="1"> <name language="sv">Ann-Marie från SWE</name></SlideShow></list>And i am using below code to read,FileStream fStream = new FileStream(path);StreamReader sr = new StreamReader(fStream);ItemController.cacheTG = sr.ReadToEnd();sr.Close();fStream.Close();
```

But when i read tghe [special character](https://www.mindstick.com/forum/119/special-character-remove-from-url-or-any-string) in the [name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide) [field](https://www.mindstick.com/forum/160867/does-mindstick-provide-training-for-field-marketing) "Ann-Marie från SWE" converts to Ann-Marie fr?n SWE. How to read the xml without changing special characters.

## Replies

### Reply by Pravesh Singh

Hi Jacob,\

This is due to encoding. You need to specify the encoding (UTF8) like this:

```
FileStream fStream = new FileStream(path);StreamReader sr = new StreamReader(fStream,
System.Text.UTF8Encoding);ItemController.cacheTG = sr.ReadToEnd();sr.Close();fStream.Close();
```


---

Original Source: https://www.mindstick.com/forum/1887/read-xml-as-a-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
