You can first load the entire file into an std::string, skip the unsupported statements and then parse the resulting document, like this:
// Open the file and read it into a vector
std::ifstream ifs("filename.xml", std::ios::in | std::ios::binary | std::ios::ate);
std::ifstream::pos_type fsize = ifs.tellg();
ifs.seekg(0, ios::beg);
std::vector<char> bytes(fsize);
ifs.read(&bytes[0], fsize);
// Create string from vector
std::string xml_str(&bytes[0], fsize);
// Skip unsupported statements
size_t pos = 0;
while (true) {
pos = xml_str.find_first_of("<", pos);
if (xml_str[pos + 1] == '?' || // <?xml...
xml_str[pos + 1] == '!') { // <!DOCTYPE... or [<!ENTITY...
// Skip this line
pos = xml_str.find_first_of("\n", pos);
} else
break;
}
xml_str = xml_str.substr(pos);
// Parse document as usual
TiXmlDocument doc;
doc.Parse(xml_str.c_str());
Additional note: if the XML file is too large, it's better to use memory mapped files instead of loading the entire file into memory. But that's another question entirely.