troubleshooting Question

XMLReader  ReadSubTree always returns None

Avatar of Janice Hobden
Janice Hobden asked on
XMLC#
5 Comments1 Solution497 ViewsLast Modified:
My XML looks like this:
<WHOLE_PAGE>
<CONSULTATION_PAGE SCREEN_NAME="Which Version">
<MESSAGE/>
<LEGEND/>
<QUESTION_ANSWER_GROUP QA_GROUP_ID="1">
<PROMPT/>
<QUESTION_ANSWER FIELD_NAME="which_version" OBJECT_NAME="Which_Version">
<QUESTION/>
<ANSWER STRING_LENGTH="" DISPLAY_LENGTH="5" DATA_TYPE="" ENTRY_MODE="Edit">1.00</ANSWER>
</QUESTION_ANSWER>
</QUESTION_ANSWER_GROUP>
</CONSULTATION_PAGE>

<CONSULTATION_PAGE SCREEN_NAME="Customer Info">
<MESSAGE/>
<LEGEND/>
<QUESTION_ANSWER_GROUP QA_GROUP_ID="1">
<PROMPT/>
<QUESTION_ANSWER FIELD_NAME="name" OBJECT_NAME="name">
<QUESTION/>
<ANSWER STRING_LENGTH="" DISPLAY_LENGTH="30" DATA_TYPE="" ENTRY_MODE="Edit">Fred</ANSWER>
</QUESTION_ANSWER>
</QUESTION_ANSWER_GROUP>

<QUESTION_ANSWER_GROUP QA_GROUP_ID="2">
<PROMPT/>
<QUESTION_ANSWER FIELD_NAME="surname" OBJECT_NAME="surname">
<QUESTION/>
<ANSWER STRING_LENGTH="" DISPLAY_LENGTH="30" DATA_TYPE="" ENTRY_MODE="Edit">Flintstone</ANSWER>
</QUESTION_ANSWER>
</QUESTION_ANSWER_GROUP>
</CONSULTATION_PAGE>

</WHOLE_PAGE>


What I'm trying to do is on reaching <CONSULTATION_PAGE> I want to create a new reader to read all the children of this element but it always returns NONE.  

This is my first time using XMLReader so its new to me... Can anyone point out the error in my code. Thanks

 static void Main(string[] args)
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreWhitespace = true;
            XmlReader xmlReader = XmlReader.Create("C:/temp/Migration/XMLTEST_001.xml");
            while (xmlReader.Read())
            {              
                if (xmlReader.IsStartElement("CONSULTATION_PAGE"))                        
                {                                            
                    XmlReader pageNodes = xmlReader.ReadSubtree();                                                                        
                }
          }
     }

Thanks
ASKER CERTIFIED SOLUTION
it_saige
Developer
Join our community to see this answer!
Unlock 1 Answer and 5 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 1 Answer and 5 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