Solved

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?

Posted on 2010-09-09
1
376 Views
Last Modified: 2013-12-17
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>

0
Comment
Question by:zimmer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 33643108
1) EndElement

XmlNodeType Enumeration
http://msdn.microsoft.com/en-us/library/system.xml.xmlnodetype(v=VS.71).aspx

   An end element tag.
   Example XML: </item>

2) Whitespace

Handling White Space with XmlTextReader
http://msdn.microsoft.com/en-us/library/aa720125(v=VS.71).aspx

• Space (ASCII space, 0x20)
• Carriage return (CR, 0x0D)
• Line feed (LF, 0x0A)
• Horizontal tab (0X09

3) Text

The text content of a node.
A Text node cannot have any child nodes. It can appear as the child node of the Attribute, DocumentFragment, Element, and EntityReference nodes
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question