LMS.ExtractXmlTag - Extract XML Tag

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > LMS. - LM-Studio Commands > NEW: LMS v2.1 Commands - Model Query, Status, and Text Extraction >

LMS.ExtractXmlTag - Extract XML Tag

Extracts content from XML-style tags in text. Useful for parsing structured AI responses that use XML tags.

Syntax:

LMS.ExtractXmlTag|$$SOURCE|$$TAG|$$OCCUR|$$RET_VAR

Parameters:

$$SOURCE (String, required) - Source text containing XML tags.

$$TAG (String, required) - Tag name without brackets (e.g., "answer").

$$OCCUR (Number, required) - Which occurrence to extract (1=first).

$$RET_VAR (Variable, required) - Variable to receive content.

Examples:

; Extract content from <answer> tags

LMS.ask|"<answer>The answer is 42</answer>"|response

LMS.ExtractXmlTag|response|answer|1|answerText

; answerText now contains "The answer is 42"

See Also:

LMS.ExtractCodeBlockLMS.ExtractCleanAnswer