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
| Signature | Description |
|---|---|
local_name() → std::string | Returns the element’s local name without its namespace |
namespace_uri() → std::string | Returns 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) → bool | Returns true when the element contains the specified attribute |
append_child(child: Ptr) → Ptr | Adds the given child node to the end of the element’s children and returns it |
add_sub_element(name: std::string_view) → Ptr | Creates 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) → Ptr | Returns 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::string | Converts 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 (&, <, >, ', "). |