在c++中使用xerces读取属性名

read attributes name in C++ using xerces

本文关键字:读取 属性 xerces c++      更新时间:2023-10-16
void MySAX2Handler::startElement(const   XMLCh* const    uri,
                        const   XMLCh* const    localname,
                        const   XMLCh* const    qname,
                        const   Attributes&     attrs)
{
  char* message = XMLString::transcode(localname);
  cout << "first element: "<< message << endl;
  XMLString::release(&message);
}

我想读取那个元素的属性,我不能显示

交货。-

<person pname="xyz">
  <dept dname="abc"/>
</person>

我想显示属性名,即pname和它的值,即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;
}

我将把名称和/或转码和/或名称空间分辨率的查找留给你:)