Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::xml::XMLParser Class Reference

Parses an XML document from a string. More...

#include "donner/base/xml/XMLParser.h"

Classes

struct  AttributeLocation
 Source location of an XML attribute in the source tree. More...
 
struct  Options
 Options to modify the parsing behavior. More...
 

Static Public Member Functions

static base::parser::ParseResult< XMLDocumentParse (std::string_view str, const Options &options=Options())
 Parse an XML string with the given options.
 
static std::optional< AttributeLocationGetAttributeLocation (std::string_view str, base::parser::FileOffset elementStartOffset, const XMLQualifiedNameRef &attributeName)
 Parse the XML attributes and get the source location of a specific attribute.
 

Detailed Description

Parses an XML document from a string.

The document tree will remain valid as long as the returned XMLDocument is alive.


Class Documentation

◆ donner::xml::XMLParser::AttributeLocation

struct donner::xml::XMLParser::AttributeLocation

Source location of an XML attribute in the source tree.

Collaboration diagram for donner::xml::XMLParser::AttributeLocation:
[legend]
Class Members
FileOffset endOffset End offset of the attribute value, in characters from the beginning of the input string.
FileOffset startOffset Start offset of the attribute value, in characters from the beginning of the input string.

Member Function Documentation

◆ GetAttributeLocation()

std::optional< XMLParser::AttributeLocation > donner::xml::XMLParser::GetAttributeLocation ( std::string_view str,
base::parser::FileOffset elementStartOffset,
const XMLQualifiedNameRef & attributeName )
static

Parse the XML attributes and get the source location of a specific attribute.

Parameters
strXML data to parse. Will not be modified.
elementStartOffsetStart offset of the element in the input string.
attributeNameName of the attribute to find.
Returns
std::optional<AttributeLocation> containing the start and end offsets of the attribute in the input string, or std::nullopt if the attribute was not found.

◆ Parse()

ParseResult< XMLDocument > donner::xml::XMLParser::Parse ( std::string_view str,
const Options & options = Options() )
static

Parse an XML string with the given options.

By default, the parser will ignore comments, the doctype node, and processing instructions. To enable parsing these nodes, configure the flags within Options.

The document tree will remain valid as long as the returned XMLDocument is alive.

Parameters
strXML data to parse. Will not be modified.
optionsOptions to modify the parsing behavior.
Returns
ParseResult containing the parsed XMLDocument, or an error if parsing failed.

The documentation for this class was generated from the following files: