Hi
Trying to create a xml file of bookmarks using the following code...
// Create the XmlDocument.
XmlDocument^ doc = gcnew XmlDocument;
//Create root
doc->LoadXml( L"<bookmarks><name>Favorite Bookmarks</name></bookmarks>" );
for(int i = 0; i < this->listView1->Items->Count; i++)
{
XmlElement^ newElement = doc->CreateElement(L"bookmark");
//Add url
XmlElement^ urlElem = doc->CreateElement( L"url" );
//Gets user added urls from listview
listView1->Focus();
this->listView1->Items[ i ]->Selected = true;
urlElem->InnerText = this->listView1->Items[i]->Text;
doc->DocumentElement->AppendChild( urlElem );
// Add a title.
XmlElement^ titleElem = doc->CreateElement( L"title" );
titleElem->InnerText = this->listView1->Items[i]->SubItems[1]->Text;
doc->DocumentElement->AppendChild( titleElem );
doc->DocumentElement->AppendChild( newElement );
}
// Save the document to a file and auto-indent the output.
XmlTextWriter^ writer = gcnew XmlTextWriter( "bookmarks.xml", nullptr );
writer->Formatting = Formatting::Indented;
doc->Save( writer );
writer->Close();
Output...
<?xml version="1.0"?>
<bookmarks>
<name>Favorite Bookmarks</name>
<url>http://www.ee.surrey.ac.uk/Teaching/Unix/</url>
<title>UNIX / Linux Tutorial for Beginners</title>
[B]<bookmark />[/B]
</bookmarks>
Desired output...
<?xml version="1.0"?>
<bookmarks>
<name>Favorite Bookmarks</name>
[B] <bookmark>[/B]
<url>http://www.ee.surrey.ac.uk/Teaching/Unix/</url>
<title>UNIX / Linux Tutorial for Beginners</title>
[B]</bookmark>[/B]
</bookmarks>
I was wondering if anyone could help why its not creating nodes correctly