zimmer9
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.t xt");
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:vers ion>
<csc:customer_name> </csc:customer_name>
<csc:request_id>DD </csc:request_id>
<csc:creation_date>2010090 9</csc:cre ation_date >
<csc:creation_time>082723< /csc:creat ion_time>
<csc:creation_host>bbd-ce< /csc:creat ion_host>
<csc:content_type>CHECK</c sc:content _type>
<csc:item_count>602</csc:i tem_count>
<csc:image_file_name>0.img </csc:imag e_file_nam e>
<csc:input_request_file></ csc:input_ request_fi le>
</csc:header>
<csc:item>
<csc:processing_date>20100 907</csc:p rocessing_ date>
<csc:item_sequence_number> 0000025004 80784</csc :item_sequ ence_numbe r>
<csc:account_number>000000 0000000444 4444</csc: account_nu mber>
<csc:check_number>00000090 3485725</c sc:check_n umber>
<csc:amount>0000305200</cs c:amount>
<csc:routing_transit>89688 8848</csc: routing_tr ansit>
<csc:bank_number>7777</csc :bank_numb er>
<csc:transaction_code></cs c:transact ion_code>
<csc:data1></csc:data1>
<csc:data2></csc:data2>
<csc:data3></csc:data3>
<csc:userField></csc:userF ield>
<csc:image_offset>17737464 </csc:imag e_offset>
<csc:image_length>019792</ csc:image_ length>
<csc:image_side>A</csc:ima ge_side>
</csc:item>
</csc:Cion_Index_File>
1) EndElement
2) Whitespace
3) Text
Snippet of code
------------------
XmlTextReader reader = new XmlTextReader("C:\\rbc.xml
StreamWriter sw = new StreamWriter("C:\\output.t
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:vers
<csc:customer_name> </csc:customer_name>
<csc:request_id>DD </csc:request_id>
<csc:creation_date>2010090
<csc:creation_time>082723<
<csc:creation_host>bbd-ce<
<csc:content_type>CHECK</c
<csc:item_count>602</csc:i
<csc:image_file_name>0.img
<csc:input_request_file></
</csc:header>
<csc:item>
<csc:processing_date>20100
<csc:item_sequence_number>
<csc:account_number>000000
<csc:check_number>00000090
<csc:amount>0000305200</cs
<csc:routing_transit>89688
<csc:bank_number>7777</csc
<csc:transaction_code></cs
<csc:data1></csc:data1>
<csc:data2></csc:data2>
<csc:data3></csc:data3>
<csc:userField></csc:userF
<csc:image_offset>17737464
<csc:image_length>019792</
<csc:image_side>A</csc:ima
</csc:item>
</csc:Cion_Index_File>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.