XmlElement

Overview

XmlElement is a class in Aspose.Slides for CPP. Inherits from: XmlElement.

Lightweight in-memory XML element for OOXML manipulation. Element names use Clark notation: {namespace-uri}local-name. Attributes are stored as simple name-value pairs.

Methods

SignatureDescription
local_name()std::stringReturns the element’s local name without its namespace
namespace_uri()std::stringReturns the namespace URI associated with the element
get(attr: std::string_view, default_val: std::string_view)std::string@} @name Attributes @{
get_optional(attr: std::string_view)std::optional<std::string>Returns an optional containing the attribute value if present
set(attr: std::string_view, value: std::string_view)Assigns the specified value to the attribute, adding it if it does not exist
remove_attribute(attr: std::string_view)Deletes the named attribute from the element
has_attribute(attr: std::string_view)boolReturns true when the element contains the specified attribute
append_child(child: Ptr)PtrAdds the given child node to the end of the element’s children and returns it
add_sub_element(name: std::string_view)PtrCreates a new sub‑element with the given name, appends it, and returns it
insert_child(index: std::size_t, child: Ptr)Inserts the child node at the specified index among the element’s children
remove_child(child: Ptr)Removes the specified child node from the element
remove_child_at(index: std::size_t)Removes the child node located at the given index
find(name: std::string_view)PtrReturns the first descendant element with the specified name or null if none
find_all(name: std::string_view)std::vector<Ptr>Returns a vector of all descendant elements matching the given name
index_of(child: Ptr)std::optional<std::size_t>Returns the index of the child if it exists, otherwise an empty optional
set_namespace(prefix: std::string_view, uri: std::string_view)@} @name Namespace map (for serialization) @{
parse(xml: std::string_view)Ptr@} @name Serialization @{
serialize(xml_declaration: bool, pretty_print: bool)std::stringConverts the element tree to an XML string, optionally including a declaration and pretty‑printing
unescape_xml(input: std::string_view)std::string@} Unescape XML entities (&, <, >, ', ").