0

Hey

I have problem... If i save playlist with 1 item then it work but if i have more then it bug. i can start debugging.

XmlTextWriter ^textWriter = gcnew XmlTextWriter(dig->FileName, nullptr);
				textWriter->WriteStartDocument();
			for(int i=0; i < listBox1->Items->Count; i++){

				textWriter->WriteStartElement("track"+ i);

			textWriter->WriteStartElement("url", "");
			textWriter->WriteString(listBox1->Items[i]->ToString());
			textWriter->WriteEndElement();

			textWriter->WriteStartElement("name", "");
			textWriter->WriteString(listBox2->Items[i]->ToString());
			textWriter->WriteEndElement();

			textWriter->WriteStartElement("start");
			textWriter->WriteString(listBox3->Items[i]->ToString());
			textWriter->WriteEndElement();

			textWriter->WriteStartElement("end");
			textWriter->WriteString(listBox3->Items[i]->ToString() + listBox4->Items[i]->ToString());
			textWriter->WriteEndElement();

			textWriter->WriteEndDocument();

			}
			textWriter->Close();
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

>If i save playlist with 1 item then it work but if i have more then it bug. i can start debugging.

Look at line 23 - Statement textWriter->WriteEndDocument(); closes the document.

XmlTextWriter ^textWriter = gcnew XmlTextWriter(dig->FileName, nullptr);

	textWriter->Formatting=Formatting::Indented;

	//Writes XML declaration
	textWriter->WriteStartDocument();

	//Writes root element (document element)
	textWriter->WriteStartElement("Root");
	for(int i=0; i<listBox1->Items->Count; i++){

		textWriter->WriteStartElement("track");

		textWriter->WriteStartElement("url", "");
		textWriter->WriteString(listBox1->Items[i]->ToString());
		textWriter->WriteEndElement();

		textWriter->WriteStartElement("name", "");
		textWriter->WriteString(listBox2->Items[i]->ToString());
		textWriter->WriteEndElement();

		textWriter->WriteStartElement("start");
		textWriter->WriteString(listBox3->Items[i]->ToString());
		textWriter->WriteEndElement();

		textWriter->WriteStartElement("end");
		textWriter->WriteString(listBox3->Items[i]->ToString() + listBox4->Items[i]->ToString());
		textWriter->WriteEndElement();

		//Close the "track"
		textWriter->WriteEndElement();

	}
	
	textWriter->WriteEndElement();  // Close the "Root"
	textWriter->WriteEndDocument(); // Close the "Document"
	textWriter->Close();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.