I am also trying to use XERCES to parse XML files. What I understand from my code debugging is , one has to use the DefaultHandler interface for parsing the XML files. Its following functions must be implemented to have access to individual elements and attributes:
startDocument();
void startElement()
void endDocument();
void endElement()
void SVGHandler::startElement(const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname,
const Attributes& attributes)
{
XMLSize_t len = attributes.getLength();
for (XMLSize_t index = 0; index < len; index++)
{
const XMLCh * attName , * nodeValue;
const XMLCh * nodeName;
nodeName = qname;
if(wcscmp(nodeName , L"svg")==0)
{
attName = attributes.getQName(index);
if(wcscmp(attName , L"height")==0)
svgProp.height = _wtol(attributes.getValue(index));
else if(wcscmp(attName , L"width")==0)
svgProp.width = _wtol(attributes.getValue(index));
}
else if(wcscmp(nodeName , L"g")==0)
{
attName = attributes.getQName(index);
if(wcscmp(attName , L"style")==0)
groupProp.gStyle.stroke = _wtol(attributes.getValue(index));
}
else if(wcscmp(nodeName , L"rect")==0)
{
attName = attributes.getQName(index);
if(wcscmp(attName , L"height")==0)
rectObj.height = _wtol(attributes.getValue(index));
else if(wcscmp(attName , L"style")==0)
rectObj.recStyle.stroke = _wtol(attributes.getValue(index));
else if(wcscmp(attName , L"width")==0)
rectObj.width = _wtol(attributes.getValue(index));
else if(wcscmp(attName , L"x")==0)
rectObj.xPos = _wtol(attributes.getValue(index));
else if(wcscmp(attName , L"y")==0)
rectObj.yPos = _wtol(attributes.getValue(index));
}
else if(wcscmp(nodeName , L"text")==0)
{
attName = attributes.getQName(index);
if(wcscmp(attName , L"x")==0)
rectObj.xPos = _wtol(attributes.getValue(index));
else if(wcscmp(attName , L"y")==0)
rectObj.yPos = _wtol(attributes.getValue(index));
}
}
}