{"library":"ltx","title":"ltx: JavaScript XML Library","description":"ltx is a JavaScript library designed for efficient XML building, parsing, serialization, and manipulation. Currently stable at version 3.1.2, it sees regular maintenance releases primarily focused on dependency updates and minor improvements, with a major version (v3.0.0) introducing significant breaking changes. A key differentiator of ltx is its performance-oriented design, offering its own fast default parser while also supporting integration with multiple third-party parsers like sax-js and saxes for more advanced XML features or specific use cases. It provides a succinct API for in-memory XML object manipulation, supports JSX compatibility via `ltx.createElement`, and offers tagged template literal support for convenient XML string creation. The library targets modern JavaScript environments and Node.js versions 12.4.0 and above. Its modular design allows users to swap out parser backends depending on performance requirements or specific XML feature needs, making it versatile for various XML processing tasks.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install ltx"],"cli":null},"imports":["import * as ltx from 'ltx';","import { Element } from 'ltx';","import { Parser } from 'ltx';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Element, Parser } from 'ltx';\n\n// 1. Build an XML element\nconst book = new Element('book', { id: 'bk101' })\n  .c('author').t('Gambardella, Matthew').up()\n  .c('title').t('XML Developer\\'s Guide').up()\n  .c('genre').t('Computer').up();\n\nconsole.log('Built XML:\\n', book.toString());\n\n// 2. Parse an XML string\nconst xmlString = `<catalog>\n  <book id=\"bk102\">\n    <author>Ralls, Kim</author>\n    <title>Midnight Rain</title>\n    <price>4.95</price>\n  </book>\n</catalog>`;\n\nconst parser = new Parser();\nlet parsedCatalog;\n\nparser.on('tree', (tree) => {\n  parsedCatalog = tree;\n});\n\nparser.parse(xmlString);\n\nconsole.log('\\nParsed XML Author:', parsedCatalog.getChild('book').getChild('author').getText());\nconsole.log('Parsed XML Book ID:', parsedCatalog.getChild('book').attrs.id);\n","lang":"typescript","description":"This quickstart demonstrates how to programmatically build an XML element, serialize it to a string, and then parse an XML string to access its properties and children using the `ltx` library's `Element` and `Parser` classes.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}