Yex.XmlFragment (y_ex v0.7.3)
View SourceA shared type to manage a collection of XML nodes. Provides functionality for manipulating XML fragments including child nodes and navigation.
Summary
Functions
Converts the XML fragment to a preliminary representation. This is useful when you need to serialize or transfer the fragment's structure.
Returns a stream of all child nodes of the XML fragment.
Deletes a range of child nodes starting at the specified index. Returns :ok on success, :error on failure.
Retrieves the child node at the specified index. Returns {:ok, node} if found, :error if index is out of bounds.
Similar to fetch/2 but raises ArgumentError if the index is out of bounds.
Returns the first child node of the XML fragment. Returns nil if the fragment has no children.
Inserts a new child node at the specified index. Returns :ok on success, :error on failure.
Inserts a new child node after the specified reference node. If the reference node is not found, inserts at the beginning. Returns :ok on success, :error on failure.
Returns the number of child nodes in the XML fragment.
Returns the parent node of this fragment. Returns nil if this is a top-level XML fragment.
Appends a new child node at the end of the children list. Returns :ok on success, :error on failure.
Returns a string representation of the XML fragment and all its child nodes.
Inserts a new child node at the beginning of the children list. Returns :ok on success, :error on failure.
Types
Functions
@spec as_prelim(t()) :: Yex.XmlFragmentPrelim.t()
Converts the XML fragment to a preliminary representation. This is useful when you need to serialize or transfer the fragment's structure.
@spec children(t()) :: Enumerable.t(Yex.XmlElement.t() | Yex.XmlText.t())
Returns a stream of all child nodes of the XML fragment.
Deletes a range of child nodes starting at the specified index. Returns :ok on success, :error on failure.
@spec fetch(t(), integer()) :: {:ok, Yex.XmlElement.t() | Yex.XmlText.t()} | :error
Retrieves the child node at the specified index. Returns {:ok, node} if found, :error if index is out of bounds.
@spec fetch!(t(), integer()) :: Yex.XmlElement.t() | Yex.XmlText.t()
Similar to fetch/2 but raises ArgumentError if the index is out of bounds.
Returns the first child node of the XML fragment. Returns nil if the fragment has no children.
@spec get(t(), integer()) :: {:ok, Yex.XmlElement.t() | Yex.XmlText.t()} | :error
Inserts a new child node at the specified index. Returns :ok on success, :error on failure.
@spec insert_after( t(), Yex.XmlElement.t() | Yex.XmlText.t(), Yex.XmlElementPrelim.t() | Yex.XmlTextPrelim.t() ) :: :ok | :error
Inserts a new child node after the specified reference node. If the reference node is not found, inserts at the beginning. Returns :ok on success, :error on failure.
Returns the number of child nodes in the XML fragment.
@spec parent(t()) :: Yex.XmlElement.t() | t() | nil
Returns the parent node of this fragment. Returns nil if this is a top-level XML fragment.
Appends a new child node at the end of the children list. Returns :ok on success, :error on failure.
Returns a string representation of the XML fragment and all its child nodes.
Inserts a new child node at the beginning of the children list. Returns :ok on success, :error on failure.