# leonidas-from-xiv/node-xml2js architecture

> Architecture diagram of the GitHub repository leonidas-from-xiv/node-xml2js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leonidas-from-xiv/node-xml2js
- Repository: https://github.com/leonidas-from-xiv/node-xml2js

## Overview

xml2js is a small Node.js library for converting XML into JavaScript objects and building XML from objects. Its main workflows enter through the public API: parsing uses a configurable SAX-backed parser and returns an object; building passes an object to a builder backed by xmlbuilder and returns XML. Defaults and processors support parsing and building options. The graph follows the sampled generated JavaScript in lib; the parallel CoffeeScript sources are not mapped separately.

Main entry points: [`lib/parser.js`](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/parser.js) (XML parser), [`lib/xml2js.js`](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/xml2js.js) (xml2js API), [`lib/builder.js`](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/builder.js) (XML builder), [`lib/defaults.js`](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/defaults.js) (Option defaults)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_api["xml2js API<br/>[xml2js.js]"]
end

subgraph group_conversion["XML Conversion"]
  node_parser["XML parser<br/>[parser.js]"]
  node_sax["SAX parser"]
  node_builder["XML builder<br/>[builder.js]"]
  node_xmlbuilder["xmlbuilder"]
end

subgraph group_support["Conversion Support"]
  node_defaults["Option defaults<br/>[defaults.js]"]
  node_processors["Value processors<br/>[processors.js]"]
  node_bom["BOM handling<br/>[bom.js]"]
end

node_caller(("Library caller"))

node_caller -->|"calls"| node_api
node_api -->|"exposes parsing"| node_parser
node_parser -->|"parses XML"| node_sax
node_parser -->|"loads options"| node_defaults
node_parser -->|"applies transforms"| node_processors
node_parser -->|"strips BOM"| node_bom
node_parser -->|"returns object"| node_caller
node_api -->|"exposes building"| node_builder
node_builder -->|"loads options"| node_defaults
node_builder -->|"creates XML"| node_xmlbuilder
node_builder -->|"returns XML"| node_caller
node_api -->|"exports defaults"| node_defaults
node_api -->|"exports processors"| node_processors

click node_api "https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/xml2js.js"
click node_parser "https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/parser.js"
click node_builder "https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/builder.js"
click node_defaults "https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/defaults.js"
click node_processors "https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/processors.js"
click node_bom "https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/bom.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api toneBlue
class node_parser,node_sax,node_builder,node_xmlbuilder toneAmber
class node_defaults,node_processors,node_bom toneMint
class node_caller toneIndigo
```

## Components

### Public API

- [xml2js API](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/xml2js.js): `lib/xml2js.js`

### XML Conversion

- [XML parser](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/parser.js): `lib/parser.js`
- **SAX parser**
- [XML builder](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/builder.js): `lib/builder.js`
- **xmlbuilder**

### Conversion Support

- [Option defaults](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/defaults.js): `lib/defaults.js`
- [Value processors](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/processors.js): `lib/processors.js`
- [BOM handling](https://github.com/leonidas-from-xiv/node-xml2js/blob/master/lib/bom.js): `lib/bom.js`

### Other components

- **Library caller**

## Connections

- Library caller → xml2js API: calls (evidence: `README.md`)
- xml2js API → XML parser: exposes parsing (evidence: `lib/xml2js.js`)
- XML parser → SAX parser: parses XML (evidence: `lib/parser.js`)
- XML parser → Option defaults: loads options (evidence: `lib/parser.js`)
- XML parser → Value processors: applies transforms (evidence: `lib/parser.js`)
- XML parser → BOM handling: strips BOM (evidence: `lib/parser.js`)
- XML parser → Library caller: returns object (evidence: `README.md`)
- xml2js API → XML builder: exposes building (evidence: `lib/xml2js.js`)
- XML builder → Option defaults: loads options (evidence: `lib/builder.js`)
- XML builder → xmlbuilder: creates XML (evidence: `lib/builder.js`)
- XML builder → Library caller: returns XML (evidence: `README.md`)
- xml2js API → Option defaults: exports defaults (evidence: `lib/xml2js.js`)
- xml2js API → Value processors: exports processors (evidence: `lib/xml2js.js`)
