I'm trying to use xerces-c to parse an xml string. I've used xsd code synthesis to generate the cxx and hxx files from the xsd that corresponds to the string. I've been trying to get it to ignore the namespace that is attributed with the xsd. In the string I receive all of the elements have the namespace in front of them: filtermessage:filterMessage. I also tried sending the xml string w/o the namespace in it. i.e just filterMessage. Either way I get this error: DOM Exception parsing, exception: expected element 'filtermessage#msgSystem'. I also tried:
auto_ptr<filterMessage> table(filterMessage_(*xmlDoc));
which gets me the same error.
The DOMNodeList* getchildren command doesn't have a problem. Does anyone know how I could get xerces-c to ignore the namespace? (I Successfully got xerces-c to parse this message but it involved me taking out the namespace from the xsd to beging with)
XercesDOMParser* parser = new XercesDOMParser();
parser->setDoNamespaces(false);
parser->setDoSchema(false);
parser->setValidationScheme(XercesDOMParser::Val_Never);
parser->parse(xmlBuf);
DOMDocument *xmlDoc;
xmlDoc = parser->getDocument();
if(!xmlDoc)
{
cout << "Failed to parse" << endl;
return;
}
DOMElement* elementRoot = xmlDoc->getDocumentElement();
if( !elementRoot )
{
cout << "empty xml doc" << endl;
fflush(stdout);
}
else
{
DOMNodeList* children = elementRoot->getChildNodes();
cout << __FILE__ << " " << __LINE__ << endl;
fflush(stdout);
filterMessage msg(*elementRoot, xml_schema::flags::dont_validate);
cout << __FILE__ << " " << __LINE__ << endl;
fflush(stdout);
}
output:
Filter.cpp 119
DOM Exception parsing, exception: expected element 'filtermessage#msgSystem'
this is the start of the string:
< filtermessage:filterMessage xmlns:filtermapping="filtermapping" xmlns:filtermessage="filtermessage">
< filtermessage:msgSystem>