parse_xml

Function parse_xml 

Source
pub fn parse_xml(value: Value, options: ParseOptions) -> Resolved
Expand description

Parses an XML string into a structured Resolved format based on the provided ParseOptions.

This function processes an XML document, applying transformations and extracting elements according to the given parsing options.

§Parameters

  • value: A vrl::value::Value containing the XML string to be parsed.
  • options: A ParseOptions struct that defines parsing behaviors, including:
    • trim: Whether to remove excess whitespace between XML elements (default: true).
    • include_attr: Whether to include XML attributes in the output (default: true).
    • attr_prefix: The prefix used for attribute keys (default: "@").
    • text_key: The key used for text content within an element (default: "text").
    • always_use_text_key: Whether text values should always be wrapped in a text key (default: false).
    • parse_bool: Whether to attempt parsing boolean values (default: true).
    • parse_null: Whether to attempt parsing null values (default: true).
    • parse_number: Whether to attempt parsing numeric values (default: true).

§Returns

  • Ok(Resolved): The structured representation of the parsed XML.
  • Err(String): If XML parsing fails or an error occurs during processing.

§Errors

  • Returns an error if the input is not valid XML or if any step in processing fails.