How to read Xml value from dataReader column

I have a DataReader reader that contains a column named LoadData strong>. LoadData contains XML data. Here is an example of how my XML is.

<employee id=="1">
<name>Abc</name>
<city>Xyz</city>
</employee>

      

How can I read this using a reader. I tried using reader.GetString () but it doesn't work. Is there any other way? This question may sound a number of times, but so far all the solutions I have found are related to SqlDataReader. I only use DataReader and also do not offer solutions with LINQ as the project I am working on uses a framework that does not support LINQ. Thank.

+3


source to share


1 answer


Try the following.

string xmlData = (string)reader["LoadData"]

      



Now load the string into an XmlDocument or XDocument to parse it.

+3


source







All Articles