Click here to Skip to main content
15,899,124 members
Home / Discussions / C#
   

C#

 
GeneralRe: how can i create public variable Pin
Ravi Bhavnani19-Sep-06 3:15
professionalRavi Bhavnani19-Sep-06 3:15 
GeneralRe: how can i create public variable Pin
S. Senthil Kumar19-Sep-06 4:11
S. Senthil Kumar19-Sep-06 4:11 
GeneralRe: how can i create public variable Pin
Ravi Bhavnani19-Sep-06 4:18
professionalRavi Bhavnani19-Sep-06 4:18 
QuestionSplitting an XML document into smaller ones Pin
bigove19-Sep-06 1:57
bigove19-Sep-06 1:57 
AnswerRe: Splitting an XML document into smaller ones Pin
S. Senthil Kumar19-Sep-06 2:34
S. Senthil Kumar19-Sep-06 2:34 
GeneralRe: Splitting an XML document into smaller ones Pin
bigove19-Sep-06 2:48
bigove19-Sep-06 2:48 
GeneralRe: Splitting an XML document into smaller ones Pin
led mike19-Sep-06 5:08
led mike19-Sep-06 5:08 
GeneralRe: Splitting an XML document into smaller ones Pin
bigove20-Sep-06 3:26
bigove20-Sep-06 3:26 
Thanks for your help so far. I have been working away and had some success; I can create a new XML file which prints the header info, then begins to cycle through and print the records as expected (hoped!). However, it crashes at the end with the following error:

"A name was started with an invalid character. Error processing resource 'file:///C:/..."

Also, the second file is created but cannot even be displayed, as it shows the following error:

"XML document must have a top level element. Error processing resource 'file:///C:/..."

My code for this is as follows:

while (fileReader != null)
{
// Create a file to write to
XmlTextWriter fileWriter = new XmlTextWriter(directory + "\\Output" + x + " myFile.xml", System.Text.Encoding.GetEncoding("ISO-8859-1"));//null);//System.Text.Encoding.UTF8);

// Write the header details to the new file
fileWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'");
fileWriter.WriteStartElement("!-- My comments go here --");
fileWriter.WriteStartElement("message");
fileWriter.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
fileWriter.WriteAttributeString("xsi", "noNamespaceSchemaLocation", null, "myXSDdoc.xsd");

// Add 'messageHeader' as the element to enclose records in the file
while (fileReader.Name != "messageHeader")
{
fileReader.Read();
}
fileWriter.WriteNode(fileReader, true);

// Write each row to the file, until 1000 records have been written
for (int i = 1; i <= 1001; i++)
{
while (fileReader.Name != "KeyRecord")
fileReader.Read();

fileWriter.WriteNode(fileReader, true);
fileWriter.Flush();
}

// Tidy up and close the file so that a new one can be opened
fileWriter.WriteEndElement();
fileWriter.Close();
x++;
}

Can anybody please help me with these errors? Thanks
Question"How can I call a function from another form" Pin
Orchid8519-Sep-06 0:59
Orchid8519-Sep-06 0:59 
AnswerRe: "How can I call a function from another form" Pin
Christian Graus19-Sep-06 1:07
protectorChristian Graus19-Sep-06 1:07 
GeneralRe: "How can I call a function from another form" Pin
Nick Parker19-Sep-06 11:54
protectorNick Parker19-Sep-06 11:54 
AnswerRe: "How can I call a function from another form" Pin
Nafiseh Salmani19-Sep-06 2:13
Nafiseh Salmani19-Sep-06 2:13 
AnswerRe: "How can I call a function from another form" Pin
Colin Angus Mackay19-Sep-06 3:08
Colin Angus Mackay19-Sep-06 3:08 
Questionstupid question Pin
faladrim19-Sep-06 0:46
faladrim19-Sep-06 0:46 
AnswerRe: stupid question Pin
Stefan Troschuetz19-Sep-06 0:58
Stefan Troschuetz19-Sep-06 0:58 
GeneralRe: stupid question Pin
faladrim19-Sep-06 1:17
faladrim19-Sep-06 1:17 
QuestionSuspend and ResumeBinding Pin
PaulPrice19-Sep-06 0:35
PaulPrice19-Sep-06 0:35 
QuestionClickOnce Updateing from an event. Pin
NaNg1524119-Sep-06 0:18
NaNg1524119-Sep-06 0:18 
Questioncreating login page Pin
arun-ice19-Sep-06 0:10
arun-ice19-Sep-06 0:10 
AnswerRe: creating login page Pin
_AK_19-Sep-06 0:22
_AK_19-Sep-06 0:22 
Questionlinear fitting Pin
Haoman1719-Sep-06 0:10
Haoman1719-Sep-06 0:10 
AnswerRe: linear fitting Pin
Christian Graus19-Sep-06 1:01
protectorChristian Graus19-Sep-06 1:01 
Questionhow to create inventory control? [modified] Pin
arun-ice19-Sep-06 0:07
arun-ice19-Sep-06 0:07 
AnswerRe: how to create inventory control? Pin
Christian Graus19-Sep-06 1:05
protectorChristian Graus19-Sep-06 1:05 
QuestionDataGridViewCell format Pin
e_LA18-Sep-06 23:50
e_LA18-Sep-06 23:50 

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.