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 🙏

© 2026 – Pkg Stats / Ryan Hefner

xmlforall

v1.0.5

Published

Simple and fast Nodejs XML parser using SAX as the only dependency.

Readme

xmlforall

Simple, fast and reliable Nodejs XML parser.

var xmlforall = require('xmlforall');
xmlforall.parse('file.xml', function (err, doc) {
});

Element

Object returned by the parse function.

Methods

getElementsByTagName(tagName)

Returns a list of Elements matching the tagName.

getElementById(id)

Returns the first matching Element with that id.

getAttribute(attr)

Returns a string attribute attr

Properties

tagName

Tag name of the element.

text

The text value of the element.

attributes

A string array of all the element attributes.

Examples

var xmlforall = require('xmlforall');
xmlforall.parse('menu.xml', function (err, doc) {
    var allItems = doc.getElementsByTagName('food'),
        item = doc.getElementById('1'),
        price = item.getElementsByTagName('price')[0],
        currency = price.getAttribute('currency');
        
    console.log('Number of items', allItems.length);
    console.log('Price of item 1:', price.text);
    console.log('Currency of item 1:', currency);
});

var xmlforall = require('xmlforall');
xmlforall.parse('menu.xml', function (err, doc) {
    var items, name, price;

    items = doc.getElementsByTagName('food');
    items.forEach(function (element) {
        name = element.getElementsByTagName('name')[0];
        price = element.getElementsByTagName('price')[0];
        console.log(
            name.text + ':',
            price.text,
            '(' + price.getAttribute('currency') + ')'
        );
    });
});

menu.xml

<!-- https://www.w3schools.com/xml/ -->
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
    <food id="0">
        <name>Belgian Waffles</name>
        <price currency="USD">$5.95</price>
        <description>
       Two of our famous Belgian Waffles with plenty of real maple syrup
       </description>
        <calories>650</calories>
    </food>
    <food id="1">
        <name>Strawberry Belgian Waffles</name>
        <price currency="USD">$7.95</price>
        <description>
        Light Belgian waffles covered with strawberries and whipped cream
        </description>
        <calories>900</calories>
    </food>
    <food id="2">
        <name>Berry-Berry Belgian Waffles</name>
        <price currency="USD">$8.95</price>
        <description>
        Belgian waffles covered with assorted fresh berries and whipped cream
        </description>
        <calories>900</calories>
    </food>
    <food id="3">
        <name>French Toast</name>
        <price currency="USD">$4.50</price>
        <description>
        Thick slices made from our homemade sourdough bread
        </description>
        <calories>600</calories>
    </food>
    <food id="4">
        <name>Homestyle Breakfast</name>
        <price currency="USD">$6.95</price>
        <description>
        Two eggs, bacon or sausage, toast, and our ever-popular hash browns
        </description>
        <calories>950</calories>
    </food>
</breakfast_menu>

Installation

$ npm install xmlforall --save

Features

  • XML Parser
  • Window.document like interface
  • Asynchronous
  • Only dependency is SAX

Test

cd node_modules/xmlforall/
node test/test.js
OR
npm test

License

MIT


Have fun!