A string which specifies the path of the (x)html file to parse.
prsr
A parser object. The parser object will contain the path/stream to parse, and any other parsing options.
Returns
Returns true if the parse was successful, false otherwise.
Remarks
This operation is used to parse an (x)html file or stream. The first variety parses a file only. The second variety can parse a file or stream,
which is determined by the parser object. The first variety uses a default parser object to parse the specified file. To
control specific parsing options, use the 2nd variety, which allows you to set options on the parser 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.