Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãOPromptsLanguage modelsOutput parsersList parserDatetime parserEnum parserAuto-fixing parserPydantic (JSON) parserRetry parserStructured output parserXML parserRetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesModel I/‚ÄãOOutput parsersXML parserXML parserThis output parser allows users to obtain results from LLM in the popular XML format. Keep in mind that large language models are leaky abstractions! You'll have to use an LLM with sufficient capacity to generate well-formed XML. In the following example we use Claude model (https://docs.anthropic.com/claude/docs) which works really well with XML tags.from langchain.prompts import PromptTemplatefrom langchain.llms import Anthropicfrom langchain.output_parsers import XMLOutputParsermodel = Anthropic(model="claude-2", max_tokens_to_sample=512, temperature=0.1)    /Users/harrisonchase/workplace/langchain/libs/langchain/langchain/llms/anthropic.py:171: UserWarning: This Anthropic LLM is deprecated. Please use `from langchain.chat_models import ChatAnthropic` instead      warnings.warn(Let's start with the simple request to the model.actor_query = "Generate the shortened filmography for Tom Hanks."output = model(    f"""Human:{actor_query}Please enclose the movies in <movie></movie> tagsAssistant:""")print(output)     Here is the shortened filmography for Tom Hanks enclosed in <movie> tags:        <movie>Splash (1984)</movie>    <movie>Big (1988)</movie>     <movie>A League of Their Own (1992)</movie>    <movie>Sleepless in Seattle (1993)</movie>      <movie>Forrest Gump (1994)</movie>    <movie>Apollo 13 (1995)</movie>    <movie>Toy Story (1995)</movie>    <movie>Saving Private Ryan (1998)</movie>    <movie>Cast Away
This output parser allows users to obtain results from LLM in the popular XML format.
This output parser allows users to obtain results from LLM in the popular XML format. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãOPromptsLanguage modelsOutput parsersList parserDatetime parserEnum parserAuto-fixing parserPydantic (JSON) parserRetry parserStructured output parserXML parserRetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesModel I/‚ÄãOOutput parsersXML parserXML parserThis output parser allows users to obtain results from LLM in the popular XML format. Keep in mind that large language models are leaky abstractions! You'll have to use an LLM with sufficient capacity to generate well-formed XML. In the following example we use Claude model (https://docs.anthropic.com/claude/docs) which works really well with XML tags.from langchain.prompts import PromptTemplatefrom langchain.llms import Anthropicfrom langchain.output_parsers import XMLOutputParsermodel = Anthropic(model="claude-2", max_tokens_to_sample=512, temperature=0.1)    /Users/harrisonchase/workplace/langchain/libs/langchain/langchain/llms/anthropic.py:171: UserWarning: This Anthropic LLM is deprecated. Please use `from langchain.chat_models import ChatAnthropic` instead      warnings.warn(Let's start with the simple request to the model.actor_query = "Generate the shortened filmography for Tom Hanks."output = model(    f"""Human:{actor_query}Please enclose the movies in <movie></movie> tagsAssistant:""")print(output)     Here is the shortened filmography for Tom Hanks enclosed in <movie> tags:        <movie>Splash (1984)</movie>    <movie>Big (1988)</movie>     <movie>A League of Their Own (1992)</movie>    <movie>Sleepless in Seattle (1993)</movie>      <movie>Forrest Gump (1994)</movie>    <movie>Apollo 13 (1995)</movie>    <movie>Toy Story (1995)</movie>    <movie>Saving Private Ryan (1998)</movie>    <movie>Cast Away