npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@max-on-27/xml-content-loader

v1.0.2

Published

A lightweight XML content loader for dynamic web content with DOM manipulation utilities

Readme

XML Content Loader

A lightweight JavaScript package for loading and displaying content from XML files in web applications.

Features

  • 🚀 Simple XML loading and parsing
  • 🎯 DOM manipulation utilities
  • 🛡️ Error handling with fallback content
  • 🌐 Browser-compatible (no Node.js dependencies for client-side)
  • 📦 Modular architecture

Installation

File-based Installation

npm install @max-on-27/xml-content-loader

Usage

Browser Usage

Include the browser bundle in your HTML:

<script src="./node_modules/xml-content-loader/browser.js"></script>

This makes three classes globally available:

  • XMLLoader - For loading and parsing XML files
  • DOMPopulator - For DOM manipulation utilities
  • XMLContentUtils - For common XML processing tasks

Basic Example

class MyLoader {
    constructor() {
        this.xmlLoader = new XMLLoader();
    }

    async loadContent() {
        try {
            const xmlDoc = await this.xmlLoader.loadXML('./data/content.xml');
            
            const title = this.xmlLoader.extractText(xmlDoc, 'title');
            const description = this.xmlLoader.extractText(xmlDoc, 'description');
            
            DOMPopulator.populateElement('page-title', title);
            DOMPopulator.populateElement('page-description', description);
            
        } catch (error) {
            XMLContentUtils.handleXMLError('content', {
                'page-title': 'Default Title',
                'page-description': 'Default description'
            });
        }
    }
}

API Reference

XMLLoader

loadXML(xmlPath)

Loads and parses an XML file from the given path.

extractText(xmlDoc, selector)

Extracts text content from an XML element using a CSS selector.

extractMultiple(xmlDoc, selector)

Returns a NodeList of elements matching the selector.

DOMPopulator

populateElement(selector, content)

Sets text content of an element.

populateHTML(selector, htmlContent)

Sets innerHTML of an element.

populateAttribute(selector, attribute, value)

Sets an attribute on an element.

clearContainer(selector)

Clears the innerHTML of a container element.

populateFromXMLNodes(containerSelector, xmlNodes, renderer, className)

Populates a container with elements created from XML nodes using a renderer function.

XMLContentUtils

handleXMLError(section, fallbackContent)

Handles XML loading errors by setting fallback content.

extractHighlights(xmlNode, selector)

Extracts highlight items from an XML node.

extractTags(xmlNode, selector)

Extracts tag items from an XML node.

createHighlightsHTML(highlights)

Creates HTML string from highlights array.

createTagsHTML(tags, className)

Creates HTML string from tags array with CSS class.

Development

The package includes:

  • src/XMLLoader.js - Core XML loading functionality
  • src/DOMPopulator.js - DOM manipulation utilities
  • src/utils.js - Helper functions and utilities
  • index.js - Node.js entry point
  • browser.js - Browser bundle with all components

License

ISC