read inner text based on a Attribute of xml node

how can I read inner text based on a Attribute of xml node?

I have the following xml file
<?xml version="1.0" encoding="utf-8" ?>
<Columns>
  <field enabled="true">Appl</field>
  <field enabled="true">Loc</field>
  <field enabled="true">RicExtn</field>
</Columns>

I am trying to open this xml file in C# and loop through each of the <field> element and if the attribute enabled="true"  then i want to extract the inntertext

i can get as far as the attibute is concerned however i'm unable to extract the inner text...

here is my code

            const string strFilename = "GroupBySelection.xml";
            XmlTextReader textReader = new XmlTextReader(strFilename);
            while (textReader.Read())
            {
                 if((textReader.NodeType == XmlNodeType.Element) && (textReader.Name == "field") )
                    if (textReader.GetAttribute("enabled") == "true")
                    {
                        //get the value of the inner text here
                    }
                       
            }

please help
LVL 5
CollindsouzaAsked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0
 
CollindsouzaAuthor Commented:
hi,

I had a look at the link and it doesnt really help me in my problem

all it does is looking trhrought the xml document using xmlReader and displaying the content...

how will it resolve my problem?
0
 
CollindsouzaAuthor Commented:
I found the solution to my problem....

here it is...

            XmlTextReader textReader = new XmlTextReader(strFilename);
            while (textReader.Read())
            {
                if ((textReader.GetAttribute("enabled") == "true") && (textReader.Name == "field"))
                {
                    ClientSelectionList.Add(textReader.ReadString());
                }
            }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.