Xport Interface: parser::doctype
Returns the doctype declaration of the input stream or file.
std::string parser::doctype() const;
Parameters
None.
Returns
Returns a string containing the doctype declaration, if any. If the doctype declaration isn't present in the stream/file, returns an empty string.
Remarks
Use this operation to determine the document type of the input
stream or file being parsed.
Complexity
Constant
Example
#include "xhtml_doc.h"
#include <iostream>
#include <sstream>
int main(int argc, char* argv[])
{
using namespace Xport;
document doc1(root_doc);
tdocument doc2(root_doc);
fdocument doc3(root_doc);
std::ostringstream ostr1, ostr2, ostr3;
formatter fmtr1(ostr1);
tformatter fmtr2(ostr2);
fformatter fmtr3(ostr3);
doc1.write(fmtr1);
doc2.write(fmtr2);
doc3.write(fmtr3);
std::istringstream istr1(ostr1.str());
std::istringstream istr2(ostr2.str());
std::istringstream istr3(ostr3.str());
parser prsr1(istr1);
parser prsr2(istr2);
parser prsr3(istr3);
std::cout << "The doctype of doc1 is:\n" << prsr1.doctype() << "\n\n";
std::cout << "The doctype of doc2 is:\n" << prsr2.doctype() << "\n\n";
std::cout << "The doctype of doc3 is:\n" << prsr3.doctype() << "\n\n";
return 0;
}