13namespace pugi {
class xml_document;
class xml_node; }
24 bool parse(std::string_view xml_string);
46 std::optional<std::string>
xpath_string(std::string_view xpath)
const;
49 void walk(std::function<
void(std::string_view name, std::string_view text)> fn)
const;
55 const std::string&
error()
const {
return error_; }
65 Impl* impl_ =
nullptr;
73 const
std::vector<
std::pair<
std::
string,
std::
string>>& elements);
bool save_file(std::string_view path) const
Save the document to a file. Returns false on failure.
std::optional< std::string > root_attribute(std::string_view name) const
Get an attribute value from the root element.
XmlDocument & operator=(const XmlDocument &)=delete
std::optional< std::string > xpath_string(std::string_view xpath) const
Get text content of the first element matching an XPath expression.
bool is_valid() const
Whether the document was parsed successfully.
Definition xml.hpp:52
std::string to_string() const
Save the document to a string.
void walk(std::function< void(std::string_view name, std::string_view text)> fn) const
Walk all elements, calling fn with (element_name, text_content).
XmlDocument(XmlDocument &&) noexcept
const std::string & error() const
Last parse error message.
Definition xml.hpp:55
XmlDocument(const XmlDocument &)=delete
std::vector< std::string > xpath_strings(std::string_view xpath) const
Find all elements matching an XPath expression.
bool load_file(std::string_view path)
Load XML from a file. Returns false on failure.
std::string root_name() const
Get the root element name.
bool parse(std::string_view xml_string)
Parse XML from a string. Returns false on failure.
Definition generated_event_source.hpp:33
std::string xml_generate(std::string_view root_name, const std::vector< std::pair< std::string, std::string > > &elements)
Generate a simple XML string from key-value pairs.