开发者

read attributes name in C++ using xerces

开发者 https://www.devze.com 2023-04-12 23:27 出处:网络
void MySAX2Handler::startElement(constXMLCh* consturi, constXMLCh* constlocalname, constXMLCh* constqname,
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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号