A string which specifies the path of the xhtml file to write.
prsr
A formatter object. The formatter object will contain the path/stream to write, and any other formatting
options.
Returns
Returns true if the write was successful, false otherwise.
Remarks
This operation is used to write an xhtml file or stream. The first variety writes to a file only. The second variety can write to a file or
stream, which is determined by the formatter object. The first variety uses a default formatter object to format the xhtml
file. To control specific formatting options, use the 2nd variety, which allows you to set options on the formatter object.
Complexity
Constant
Example
1st Variety
#include "xhtml_doc.h"
#include "xport_brochure.h"
#include <iostream>
#include <sstream>
int main(int argc, char* argv[])
{
using namespace Xport;
// create an xhtml strict root document and stylesheet
document doc(root_doc);
stylesheet ss;
// populate doc and stylesheet
xport_brochure broch;
broch.create(doc, ss);
doc.insert(ss);
// write document to a stream
std::cout << "Writing Xport brochure document to a file\n\n";
doc.write("c:/xport_brochure.htm");
// create another document object and parse the file
std::cout << "Parsing Xport brochure document from the stream.\n\n";
document doc2;
doc2.parse("c:/xport_brochure.htm");
// compare documents
std::cout << "Comparing original document to parsed document.\n";
std::ostringstream ostr1, ostr2;
formatter fmtr1(ostr1);
formatter fmtr2(ostr2);
doc.write(fmtr1);
doc.write(fmtr2);
bool eq = ostr1.str() == ostr2.str();
std::cout << "Documents are " << (eq ? "" : "not") << " identical!\n\n";
return 0;
}
2nd Variety
#include "xhtml_doc.h"
#include "xport_brochure.h"
#include <iostream>
#include <sstream>
int main(int argc, char* argv[])
{
using namespace Xport;
// create an xhtml strict root document and stylesheet
document doc(root_doc);
stylesheet ss;
// populate doc and stylesheet
xport_brochure broch;
broch.create(doc, ss);
doc.insert(ss);
// write document to a stream
std::cout << "Writing Xport brochure document to a stream\n\n";
std::ostringstream ostr;
formatter fmtr(ostr);
doc.write(fmtr);
// create an input stream for the document
std::istringstream istr(ostr.str());
// create another document object and parse the stream
std::cout << "Parsing Xport brochure document from the stream.\n\n";
document doc2;
parser prsr(istr);
doc2.parse(prsr);
// compare documents
std::cout << "Comparing parsed document to original document.\n";
bool eq = istr.str() == ostr.str();
std::cout << "Documents are " << (eq ? "" : "not") << " identical!\n\n";
return 0;
}
Datasoft Solutions is proud to present their landmark product, Work Time Studio. Utilizing the tree container library, Work Time Studio provides
unparalleled features in personal time, project and task management
software. If you're looking for a way to increase your productivity,
visit Work Time Studio's product website, and start being more productive
today.