XML: read and write with Node.js

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
Sevalla - Deploy and host your apps and databases, now with $50 credit!
Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!
sevalla.com
featured
  1. blog.johnnyreilly.com

    This is the source code for https://johnnyreilly.com

    import { XMLParser, XMLBuilder } from 'fast-xml-parser'; import fs from 'fs'; import path from 'path'; interface Sitemap { urlset: { url: { loc: string; changefreq: string; priority: number }[]; }; } async function trimXML() { const sitemapPath = path.resolve( '..', 'blog-website', 'build', 'sitemap.xml' ); console.log(`Loading ${sitemapPath}`); const sitemapXml = await fs.promises.readFile(sitemapPath, 'utf8'); const parser = new XMLParser({ ignoreAttributes: false, }); let sitemap: Sitemap = parser.parse(sitemapXml); const rootUrl = 'https://blog.johnnyreilly.com'; const filteredUrls = sitemap.urlset.url.filter( (url) => url.loc !== `${rootUrl}/tags` && !url.loc.startsWith(rootUrl + '/tags/') && !url.loc.startsWith(rootUrl + '/page/') ); console.log( `Reducing ${sitemap.urlset.url.length} urls to ${filteredUrls.length} urls` ); sitemap.urlset.url = filteredUrls; const builder = new XMLBuilder({ format: false, ignoreAttributes: false }); const shorterSitemapXml = builder.build(sitemap); console.log(`Saving ${sitemapPath}`); await fs.promises.writeFile(sitemapPath, shorterSitemapXml); } trimXML();

  2. InfluxDB

    InfluxDB – Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.

    InfluxDB logo
  3. fast-xml-parser

    Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.

    After experimenting with a few different XML parsers I settled on fast-xml-parser. It's fast, it's simple and it's well maintained. It also handles XML namespaces and attributes well. (This appears to be rare in XML parsers.)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Fast-XML-Parser: Validate XML, Parse XML and Build XML Rapidly

    1 project | news.ycombinator.com | 11 Sep 2024
  • Submit form display data from outsource xml

    2 projects | /r/react | 19 Jun 2021
  • Xml2Json - convert xml strings to json and vise versa, binding to a Rust lib

    3 projects | /r/ruby | 3 Oct 2023
  • Convert from XML to JSON (and back again)

    1 project | /r/learnjavascript | 27 Jul 2022
  • Need help in stripping the data from HTML/XML code from react.

    1 project | /r/reactjs | 18 Mar 2022