troubleshooting Question

XMLReader question

Avatar of Arnold Layne
Arnold LayneFlag for United States of America asked on
.NET ProgrammingC#ASP.NET
6 Comments2 Solutions411 ViewsLast Modified:
Here is the source code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
namespace ConsoleApplication1
    class Program
        static void Main(string[] args)

        static void ReadXML()
            XmlReader reader = XmlReader.Create(@Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test1.xml");
            while (reader.Read())
                if (reader.NodeType == XmlNodeType.Text)

            reader = XmlReader.Create(@Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test1.xml");
                Console.WriteLine("read to following method value " + reader.ReadInnerXml());



XML file
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<chapters total="2">

Both sections print out the same thing, chapter1 and chapter2.

Why does the first section of the code have to use reader.Value and the second section has to use reader.ReadInnerXML? If I swap the two or use one of the two in both instances, it does not work. So they are not interchangeable
Carl Tawn
Senior Systems and Integration Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros