Click here to Skip to main content
15,909,373 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Use __LINE__ & __FUNCTION__ in C# Pin
Nader Elshehabi25-Sep-06 1:25
Nader Elshehabi25-Sep-06 1:25 
QuestionHow do you read the end of an XML file in C#? Pin
bigove24-Sep-06 22:55
bigove24-Sep-06 22:55 
AnswerRe: How do you read the end of an XML file in C#? Pin
Ed.Poore24-Sep-06 23:04
Ed.Poore24-Sep-06 23:04 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove24-Sep-06 23:52
bigove24-Sep-06 23:52 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore25-Sep-06 0:36
Ed.Poore25-Sep-06 0:36 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove25-Sep-06 1:58
bigove25-Sep-06 1:58 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore25-Sep-06 2:08
Ed.Poore25-Sep-06 2:08 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove25-Sep-06 2:55
bigove25-Sep-06 2:55 
Here is my code:

while (XmlReader.Read() && nodeCounter <= 1000)

{


// Create a file to write to

XmlTextWriter XmlWriter = new XmlTextWriter(directory + "\\Output" + x + " CIS_KASN.xml", null);

XmlWriter.Formatting = Formatting.Indented;



// Write the header details to the new file

XmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'");

XmlWriter.WriteComment("This XML message contains CIS Key Accounts and Special Needs records for inserting/updating in the IAR");

XmlWriter.WriteStartElement("message");

XmlWriter.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");

XmlWriter.WriteAttributeString("xsi", "noNamespaceSchemaLocation", null, "CISKASN.xsd");




// Write each row to the file, until 1000 records have been written


for (int i = 1; i <= 1000; i++)

{

while (XmlReader.Name != "CISKASNRecord")

{

XmlReader.Read();

}

XmlWriter.WriteNode(XmlReader, true);

XmlWriter.Flush();

}

// Tidy up and close the file so that a new one can be opened

XmlWriter.Flush();

XmlWriter.Close();

nodeCounter++;

x++;

}



The program runs fine if I reduce my for-loop to 10 (thus not reading the end of file). At 1000 I get an XML error saying the 'message' tag is not closed and the program doesn't complete...
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore25-Sep-06 4:54
Ed.Poore25-Sep-06 4:54 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove25-Sep-06 5:24
bigove25-Sep-06 5:24 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore25-Sep-06 6:13
Ed.Poore25-Sep-06 6:13 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore25-Sep-06 6:15
Ed.Poore25-Sep-06 6:15 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove25-Sep-06 22:13
bigove25-Sep-06 22:13 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore25-Sep-06 23:28
Ed.Poore25-Sep-06 23:28 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove25-Sep-06 23:44
bigove25-Sep-06 23:44 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore26-Sep-06 0:03
Ed.Poore26-Sep-06 0:03 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove26-Sep-06 0:20
bigove26-Sep-06 0:20 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore26-Sep-06 0:25
Ed.Poore26-Sep-06 0:25 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove26-Sep-06 0:36
bigove26-Sep-06 0:36 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore26-Sep-06 1:05
Ed.Poore26-Sep-06 1:05 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove26-Sep-06 1:25
bigove26-Sep-06 1:25 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore26-Sep-06 1:30
Ed.Poore26-Sep-06 1:30 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove26-Sep-06 1:35
bigove26-Sep-06 1:35 
GeneralRe: How do you read the end of an XML file in C#? Pin
Ed.Poore26-Sep-06 1:49
Ed.Poore26-Sep-06 1:49 
GeneralRe: How do you read the end of an XML file in C#? Pin
bigove26-Sep-06 2:53
bigove26-Sep-06 2:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.