camster123
asked on
How can one write newline characters between TiXmLText elements in a Tiny XML DOM Object using Visual Studio 2008 C++?
I am using TinyXML library in my project to produce a Xml file. (C++ Visual Studio 2008).
I want to write each name in one line but all of them between a couple tags. I would like the output format below:
<?xml version="1.0"?>
<opencv_storage>
<images>
./images/cam01.jpg
./images/cam02.jpg
./images/cam03.jpg
./images/cam04.jpg
./images/cam05.jpg
./images/cam06.jpg
./images/cam07.jpg
./images/cam08.jpg
./images/cam09.jpg
./images/cam10.jpg
./images/cam11.jpg
./images/cam12.jpg
./images/cam13.jpg
./images/cam14.jpg
</images>
</opencv_storage>
but I dont know How can I write the new line between them . by my code here:
TiXmlDocument document;
TiXmlElement* msg;
TiXmlDeclaration* dec1 = new TiXmlDeclaration("1.0","", "");
document.LinkEndChild(dec1 );
TiXmlElement * root = new TiXmlElement( "opencv_storage" );
document.LinkEndChild( root );
msg = new TiXmlElement("images");
openFileDialog1->Title = "Select an Image file";
if (openFileDialog1->ShowDial og() == System::Windows::Forms::Di alogResult ::OK)
{
for each (String^ file in openFileDialog1->SafeFileN ames)
{
std::stringstream v;
v << openFileDialog1->FileName;
TiXmlText* txt = new TiXmlText(v.str());
msg->LinkEndChild(txt);
}
root->LinkEndChild(msg);
document.SaveFile("VID5.xm l");
}
by this Code I produce such file :
<?xml version="1.0" ?>
<opencv_storage>
<images>C:\Users\Public\Pi ctures\Sam ple Pictures\Chrysanthemum.jpg C:\Users\P ublic \Pictures\Sample Pictures\Chrysanthemum.jpg
</images>
</opencv_storage>
How Can I write a newline character between these names ?
Any help is greatly appreciated.
I want to write each name in one line but all of them between a couple tags. I would like the output format below:
<?xml version="1.0"?>
<opencv_storage>
<images>
./images/cam01.jpg
./images/cam02.jpg
./images/cam03.jpg
./images/cam04.jpg
./images/cam05.jpg
./images/cam06.jpg
./images/cam07.jpg
./images/cam08.jpg
./images/cam09.jpg
./images/cam10.jpg
./images/cam11.jpg
./images/cam12.jpg
./images/cam13.jpg
./images/cam14.jpg
</images>
</opencv_storage>
but I dont know How can I write the new line between them . by my code here:
TiXmlDocument document;
TiXmlElement* msg;
TiXmlDeclaration* dec1 = new TiXmlDeclaration("1.0","",
document.LinkEndChild(dec1
TiXmlElement * root = new TiXmlElement( "opencv_storage" );
document.LinkEndChild( root );
msg = new TiXmlElement("images");
openFileDialog1->Title = "Select an Image file";
if (openFileDialog1->ShowDial
{
for each (String^ file in openFileDialog1->SafeFileN
{
std::stringstream v;
v << openFileDialog1->FileName;
TiXmlText* txt = new TiXmlText(v.str());
msg->LinkEndChild(txt);
}
root->LinkEndChild(msg);
document.SaveFile("VID5.xm
}
by this Code I produce such file :
<?xml version="1.0" ?>
<opencv_storage>
<images>C:\Users\Public\Pi
</images>
</opencv_storage>
How Can I write a newline character between these names ?
Any help is greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think endl will flush the buffer or stream.
ASKER