MCPcopy Index your code
hub / github.com/TIGER-AI-Lab/TheoremExplainAgent / extract_xml

Function extract_xml

src/utils/utils.py:114–128  ·  view source on GitHub ↗

Extract XML content from a text response. Extracts XML content between ```xml markers. Returns the full response if no XML blocks found. Args: response (str): The text response containing XML content Returns: str: The extracted XML content, or the full response if no X

(response: str)

Source from the content-addressed store, hash-verified

112 return text
113
114def extract_xml(response: str) -> str:
115 """Extract XML content from a text response.
116
117 Extracts XML content between ```xml markers. Returns the full response if no XML blocks found.
118
119 Args:
120 response (str): The text response containing XML content
121
122 Returns:
123 str: The extracted XML content, or the full response if no XML blocks found
124 """
125 try:
126 return re.search(r'```xml\n(.*?)\n```', response, re.DOTALL).group(1)
127 except:
128 return response

Calls

no outgoing calls

Tested by

no test coverage detected