{"library":"mjml-parser-xml","title":"MJML XML Parser","description":"mjml-parser-xml is a fundamental, internal package within the MJML ecosystem, currently at stable version 5.0.1. Its primary function is to parse MJML (Mailjet Markup Language) XML strings into an Abstract Syntax Tree (AST) or a similar structured JavaScript object representation. While this package is not typically accessed directly by end-users, who generally interact with the higher-level `mjml` package and its `mjml2html` function, it is a critical component that underpins the entire MJML conversion process. The parser translates MJML's declarative, semantic XML-like syntax into an intermediate format that the MJML engine can then process and render into robust, responsive HTML. The MJML project maintains an active and consistent development cadence, with frequent updates across its monorepo, including alpha and beta releases for major versions, ensuring ongoing compatibility with evolving email client standards and web practices.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mjml-parser-xml"],"cli":null},"imports":["import MJMLParser from 'mjml-parser-xml';","const MJMLParser = require('mjml-parser-xml');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import MJMLParser from 'mjml-parser-xml';\n\nconst mjmlString = `\n  <mjml>\n    <mj-body>\n      <mj-section>\n        <mj-column>\n          <mj-text font-size=\"20px\" color=\"#F45E43\">Hello MJML World!</mj-text>\n        </mj-column>\n      </mj-section>\n    </mj-body>\n  </mjml>\n`;\n\ntry {\n  // Parse the MJML string into an AST (Abstract Syntax Tree) object\n  const ast = MJMLParser(mjmlString, {\n    // Optional configurations\n    keepComments: false, // Do not keep comments in the parsed output\n    filePath: './templates', // Base path for mj-include directives\n  });\n\n  console.log('Successfully parsed MJML to AST:');\n  console.log(JSON.stringify(ast, null, 2));\n\n  // Example of accessing a node (simplified, actual AST structure is more complex)\n  if (ast && ast.children && ast.children.length > 0) {\n    const firstBodyChild = ast.children[0];\n    console.log('\\nFirst child of mj-body:', firstBodyChild.tagName);\n  }\n\n} catch (error) {\n  console.error('Error parsing MJML:', error);\n}","lang":"typescript","description":"This quickstart demonstrates how to import the `MJMLParser` and use it to convert a raw MJML string into its corresponding Abstract Syntax Tree (AST) object, illustrating basic parsing functionality and options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}