Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

What causes the value of "reader.NodeType" to have 1 of the following 3 values when reading a record an XML file: EndElement, Whitespace, Text?

I am writing my first C# Console application and I'm trying to understand what causes the value of  "reader.NodeType" to have 1 of the following 3 values when reading a record from the following XML file:
1) EndElement
2) Whitespace
3) Text

Snippet of code
------------------
XmlTextReader reader = new XmlTextReader("C:\\rbc.xml");      
            StreamWriter sw = new StreamWriter("C:\\output.txt");
            while (reader.Read())            
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "csc:check_number")

Sample XML file:
--------------------------
<?xml version="1.0"?>
<csc:Cion_Index_File
    xmlns:csc="http://rt.csc.com/xml/Cion_Index_File">
<csc:header>
    <csc:version>1.0</csc:version>
    <csc:customer_name>              </csc:customer_name>
    <csc:request_id>DD </csc:request_id>
    <csc:creation_date>20100909</csc:creation_date>
    <csc:creation_time>082723</csc:creation_time>
    <csc:creation_host>bbd-ce</csc:creation_host>
    <csc:content_type>CHECK</csc:content_type>
    <csc:item_count>602</csc:item_count>
    <csc:image_file_name>0.img</csc:image_file_name>
    <csc:input_request_file></csc:input_request_file>
</csc:header>
<csc:item>
    <csc:processing_date>20100907</csc:processing_date>
    <csc:item_sequence_number>000002500480784</csc:item_sequence_number>
    <csc:account_number>00000000000004444444</csc:account_number>
    <csc:check_number>000000903485725</csc:check_number>
    <csc:amount>0000305200</csc:amount>
    <csc:routing_transit>896888848</csc:routing_transit>
    <csc:bank_number>7777</csc:bank_number>
    <csc:transaction_code></csc:transaction_code>
    <csc:data1></csc:data1>
    <csc:data2></csc:data2>
    <csc:data3></csc:data3>
    <csc:userField></csc:userField>
    <csc:image_offset>17737464</csc:image_offset>
    <csc:image_length>019792</csc:image_length>
    <csc:image_side>A</csc:image_side>
</csc:item>
</csc:Cion_Index_File>

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial