I suggest xml2js, a simple XML to JavaScript object converter. You can then iterate the resulting object. Code snippet from the page :

var parseString = require('xml2js').parseString;
var xml = "<root>Hello xml2js!</root>"
parseString(xml, function (err, result) {
    console.dir(result);
});

You can install it by using npm install xml2js

Answer from user568109 on Stack Overflow
🌐
npm
npmjs.com › package › xml-parse-from-string
xml-parse-from-string - npm
May 18, 2017 - Parses the string as XML and returns the root element as a DOM element, so you can do operations similar to document.getElementById, document.getElementsByTagName, and so forth.
      » npm install xml-parse-from-string
    
Published   May 18, 2017
Version   1.0.1
Author   Matt DesLauriers
🌐
npm
npmjs.com › package › to-xml
to-xml - npm
August 21, 2023 - Simple: single writer function toXML() which returns XML string.
      » npm install to-xml
    
Published   Aug 21, 2023
Version   0.1.11
Author   Yusuke Kawasaki
🌐
npm
npmjs.com › package › xml-js
xml-js - npm
February 13, 2019 - Reversible: Whether converting xml→json or json→xml, the result can be converted back to its original form. Minimal Dependencies: This library depends only on one external npm module.
      » npm install xml-js
    
Published   Feb 13, 2019
Version   1.6.11
Author   Yousuf Almarzooqi
🌐
LogRocket
blog.logrocket.com › home › reading and writing xml in node.js
Reading and writing XML in Node.js - LogRocket Blog
June 4, 2024 - In this article, we will explore some real-world XML use cases using some of the most popular npm packages available, including: ... Note that the code examples in this article are for demonstration purposes. Elaborate, working sample code is available at briandesousa/node-xml-demo. If you want to follow along with the instructions in this article, you may want to start by generating an Express app with express-generator.
🌐
Devextent
devextent.com › npm-convert-json-to-xml
Convert JSON to XML with the XML npm package | Dev Extent
March 23, 2021 - Read a JSON file with Node.js and use the XML npm package with TypeScript to convert JSON to an XML string and write the XML string to a file.
🌐
npm
npmjs.com › package › fast-xml-parser
fast-xml-parser - npm
6 days ago - Validate XML, Parse XML, Build XML without C/C++ based libraries. Latest version: 5.5.9, last published: 5 days ago. Start using fast-xml-parser in your project by running `npm i fast-xml-parser`. There are 3909 other projects in the npm registry using fast-xml-parser.
      » npm install fast-xml-parser
    
Published   Mar 23, 2026
Version   5.5.9
Author   Amit Gupta
🌐
npm
npmjs.com › package › xml-string
xml-string - npm
February 10, 2020 - Latest version: 2.0.2, last published: 6 years ago. Start using xml-string in your project by running `npm i xml-string`. There are 3 other projects in the npm registry using xml-string.
      » npm install xml-string
    
Published   Feb 10, 2020
Version   2.0.2
🌐
GitHub
github.com › jhuckaby › pixl-xml
GitHub - jhuckaby/pixl-xml: A simple module for parsing and composing XML. · GitHub
Can parse XML strings, Buffers or load from files · Can preserve or flatten attributes · Can convert all keys to lower-case · Can serialize objects back to pretty-printed or compact XML · Use npm to install the module: npm install pixl-xml · ...
Starred by 78 users
Forked by 19 users
Languages   JavaScript
Find elsewhere
🌐
npm
npmjs.com › package › xml-core
xml-core - npm
npm install xml-core · Convert XML to JSON and JSON to XML with schema enforcement · TypeScript decorators for XML element definitions · Support for attributes, child elements, and content · Cross-platform compatibility (browser and Node.js) import { XmlObject, XmlElement, XmlAttribute, XmlChildElement } from "xml-core"; @XmlElement({ localName: "Person" }) class Person extends XmlObject { @XmlAttribute({ localName: "id" }) public id: string = ""; @XmlChildElement({ localName: "Name" }) public name: string = ""; } // Parse XML const person = new Person(); person.LoadXml('<Person id="123"><
      » npm install xml-core
    
Published   Dec 15, 2025
Version   1.2.5
Author   Peculiar Ventures LLC
🌐
npm
npmjs.com › package › xml-parse
xml-parse - npm
November 6, 2019 - Parse XML, HTML and more with a very tolerant XML parser and convert it into a DOM. These three components are separated from each other as own modules. npm install xml-parse · const xml = require("xml-parse"); Parsing is very simple.
      » npm install xml-parse
    
Published   Nov 06, 2019
Version   0.4.0
Author   Maurice Conrad
🌐
npm
npmjs.com › package › jsontoxml
jsontoxml - npm
This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures.. Latest version: 1.0.1, last published: 7 years ago. Start using jsontoxml in your project by running `npm i jsontoxml`. There are 132 other projects in the npm registry ...
      » npm install jsontoxml
    
Published   Oct 01, 2018
Version   1.0.1
🌐
npm
npmjs.com › search
json to xml - npm search
A library for fast JSON to XML transformations.
🌐
npm
npmjs.com › package › xml2js
xml2js - npm
You can create one xml2js.Parser per file. That's the recommended one and is promised to always just work. You can call reset() on your parser object. You can hope everything goes well anyway. This behaviour is not guaranteed work always, if ever. Use option #1 if possible. Thanks! Just wrap the result object in a call to JSON.stringify like this JSON.stringify(result).
      » npm install xml2js
    
Published   Jul 26, 2023
Version   0.6.2
Author   Marek Kubica
🌐
npm
npmjs.com › package › xml-element-string
xml-element-string - npm
June 12, 2016 - Takes a tag-name, attributes object, and an array of children and turns them into an xml string. Latest version: 1.0.0, last published: 9 years ago. Start using xml-element-string in your project by running `npm i xml-element-string`. There ...
      » npm install xml-element-string
    
Published   Jun 12, 2016
Version   1.0.0
Author   Mike Cousins
🌐
GitHub
github.com › ElyaConrad › XML-Parser
GitHub - ElyaConrad/XML-Parser: A Node.js XML DOM, Parser & Stringifier. · GitHub
Just call the parse method of the xml-parse instance. const xml = require("xml-parse"); // Valid XML string var parsedXML = xml.parse('<?xml version="1.0" encoding="UTF-8"?>' + '<root>Root Element</root>'); console.log(parsedXML); // Invalid ...
Starred by 18 users
Forked by 7 users
Languages   JavaScript
🌐
npm
npmjs.com › package › xmlbuilder
xmlbuilder - npm
April 8, 2020 - An XML builder for node.js similar to java-xmlbuilder.
      » npm install xmlbuilder
    
Published   Apr 08, 2020
Version   15.1.1
Author   Ozgur Ozcitak
🌐
Geshan
geshan.com.np › blog › 2022 › 11 › nodejs-xml-parser
A beginner’s guide to parse and create XML with Node.js
November 27, 2022 - In this tutorial, learn how validate and parse XML with Node.js. You will also know about creating a XML file with Node.js
🌐
Medium
medium.com › @tariibaba › javascript-convert-json-to-xml-80caf3148886
How to Convert JSON to XML in JavaScript | Medium
September 16, 2022 - import { json2xml } from 'xml-js';const jsonObj = { name: 'Garage', cars: [ { color: 'red', maxSpeed: 120, age: 2 }, { color: 'blue', maxSpeed: 100, age: 3 }, { color: 'green', maxSpeed: 130, age: 2 }, ], };const json = JSON.stringify(jsonObj);const ...
🌐
UsefulAngle
usefulangle.com › post › 106 › nodejs-read-xml
Reading XML in Node.js - UsefulAngle
January 3, 2019 - npm install xml2js --save · The installed module exposes the Parser object, which is then used to read XML. const xml2js = require('xml2js'); const fs = require('fs'); const parser = new xml2js.Parser({ attrkey: "ATTR" }); // this example reads ...