_root_to_dict() — langchain Function Reference
Architecture documentation for the _root_to_dict() function in xml.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bc7e3795_e9e2_9111_e066_976d85188623["_root_to_dict()"] b51fd3dc_a25e_9ad9_8893_3725f5d436f0["XMLOutputParser"] bc7e3795_e9e2_9111_e066_976d85188623 -->|defined in| b51fd3dc_a25e_9ad9_8893_3725f5d436f0 698aa558_20db_aa12_47eb_de459e25e934["parse()"] 698aa558_20db_aa12_47eb_de459e25e934 -->|calls| bc7e3795_e9e2_9111_e066_976d85188623 bc7e3795_e9e2_9111_e066_976d85188623["_root_to_dict()"] bc7e3795_e9e2_9111_e066_976d85188623 -->|calls| bc7e3795_e9e2_9111_e066_976d85188623 bc7e3795_e9e2_9111_e066_976d85188623["_root_to_dict()"] bc7e3795_e9e2_9111_e066_976d85188623 -->|calls| bc7e3795_e9e2_9111_e066_976d85188623 style bc7e3795_e9e2_9111_e066_976d85188623 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/output_parsers/xml.py lines 269–281
def _root_to_dict(self, root: ET.Element) -> dict[str, str | list[Any]]:
"""Converts xml tree to python dictionary."""
if root.text and bool(re.search(r"\S", root.text)):
# If root text contains any non-whitespace character it
# returns {root.tag: root.text}
return {root.tag: root.text}
result: dict = {root.tag: []}
for child in root:
if len(child) == 0:
result[root.tag].append({child.tag: child.text})
else:
result[root.tag].append(self._root_to_dict(child))
return result
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does _root_to_dict() do?
_root_to_dict() is a function in the langchain codebase, defined in libs/core/langchain_core/output_parsers/xml.py.
Where is _root_to_dict() defined?
_root_to_dict() is defined in libs/core/langchain_core/output_parsers/xml.py at line 269.
What does _root_to_dict() call?
_root_to_dict() calls 1 function(s): _root_to_dict.
What calls _root_to_dict()?
_root_to_dict() is called by 2 function(s): _root_to_dict, parse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free