void MySAX2Handler::startElement(const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname,
const Attributes& attrs)
{
char* message = XMLString::transcode(localname开发者_JAVA技巧);
cout << "first element: "<< message << endl;
XMLString::release(&message);
}
I want to read attributes of that element, i am not able to display
ex. -
<person pname="xyz">
<dept dname="abc"/>
</person>
I want to display attribute name i.e., pname and its value i.e., xyz
http://xerces.apache.org/xerces-c/apiDocs-3/classAttributeList.html
for (int i=0; i< attrs.getLength(); i++)
{
std::cout << attrs.getName(i) << std::cout << attrs.getValue(i) << std::endl;
}
I'll leave looking up by name and/or transcoding and/or namespace resolutions up to you :)
精彩评论