Home / Function/ _xml_to_dict() — langchain Function Reference

_xml_to_dict() — langchain Function Reference

Architecture documentation for the _xml_to_dict() function in experimental.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5caceaa3_b456_6fdf_116f_ca7f168a1487["_xml_to_dict()"]
  ce9a5118_b2cf_f25f_fad5_ea15575e8265["experimental.py"]
  5caceaa3_b456_6fdf_116f_ca7f168a1487 -->|defined in| ce9a5118_b2cf_f25f_fad5_ea15575e8265
  2f365234_b69d_08fc_8892_b7529ec51dbf["_xml_to_function_call()"]
  2f365234_b69d_08fc_8892_b7529ec51dbf -->|calls| 5caceaa3_b456_6fdf_116f_ca7f168a1487
  style 5caceaa3_b456_6fdf_116f_ca7f168a1487 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/langchain_anthropic/experimental.py lines 85–100

def _xml_to_dict(t: Any) -> str | dict[str, Any]:
    # Base case: If the element has no children, return its text or an empty string.
    if len(t) == 0:
        return t.text or ""

    # Recursive case: The element has children. Convert them into a dictionary.
    d: dict[str, Any] = {}
    for child in t:
        if child.tag not in d:
            d[child.tag] = _xml_to_dict(child)
        else:
            # Handle multiple children with the same tag
            if not isinstance(d[child.tag], list):
                d[child.tag] = [d[child.tag]]  # Convert existing entry into a list
            d[child.tag].append(_xml_to_dict(child))
    return d

Domain

Subdomains

Frequently Asked Questions

What does _xml_to_dict() do?
_xml_to_dict() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/experimental.py.
Where is _xml_to_dict() defined?
_xml_to_dict() is defined in libs/partners/anthropic/langchain_anthropic/experimental.py at line 85.
What calls _xml_to_dict()?
_xml_to_dict() is called by 1 function(s): _xml_to_function_call.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free