Skip to content

IXmlEntityVisitor#

Visits an xml entity (element).

Header:#include <AUI/Xml/IXmlEntityVisitor.h>
CMake:aui_link(my_target PUBLIC aui::xml)

Detailed Description#

One instance corresponds to one element. The parser calls its methods in document order:

  • visitAttribute for each attribute in the opening tag. An attribute without a value gets an empty string.
  • visitTextEntity for text between tags.
  • visitEntity for each nested element. Return a visitor which will receive the nested element, or nullptr to skip the element along with its contents.

All methods have empty default implementations, so override only what you need.

struct Point: IXmlEntityVisitor {
    int x = 0, y = 0;
    void visitAttribute(const AString& name, AString value) override {
        if (name == "x") x = value.toInt().valueOr(0);
        if (name == "y") y = value.toInt().valueOr(0);
    }
};

See Parsing XML.