0

I'm using an xmlreader to parse a valid xml file. I start reading and have an if statement like so:

if (reader.IsStartElement())
{
     // Code needed here

How do I grab just the name of that start element?

2
  • 2
    Why use XmlReader? And I suggest you look at the "Related questions" on the right. And this is not ASP Classic. Commented Aug 22, 2013 at 0:48
  • MSDN? msdn.microsoft.com/en-us/library/xaxy929c.aspx Commented Aug 22, 2013 at 1:02

1 Answer 1

1

You can just check the value of reader.Name

if (reader.IsStartElement())
{
     if (reader.Name == "settings")
     {
          //do stuff

But as the others suggested, you might want to read more documentation about XmlReader, and perhaps even think about simply parsing the full xml document with XDocument etc.

Sign up to request clarification or add additional context in comments.

1 Comment

I think there's typo. reader.Name = "settings" should be changed to ==

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.