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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lazy-xml-parser

v1.1.6

Published

A lazily made XML parser for NodeJS. Lazy, but fast, really fucking awesome fast.

Downloads

13

Readme

lazy-xml-parser

A lazily made XML parser for NodeJS. Lazy, but fast, really fucking awesome fast.

IMPORTANT: The reason why I made this XML parser is becouse all of the current XML parsers in NPM fucks up the xml somehow, since I work for the translation industry it is really important that the XML structure, tag ordering and code identation are not changed. So this XML parser respect the original XML file (reading and saving the same file will result in identical matches).

Ps.: also great at memory usage, using really low memory

Ps2.: lazy means that I did not take the time to make it report errors properly, but it work perfectly with XML files that are not broken

Example

const xmlParser = require("lazy-xml-parser");

xmlParser.toJs('/path/to/file.xml', (xmlAsObject) =>{
    
    console.dir(xmlAsObject);
    //manipulate it as you want
    ...
    //save it as xml
    xmlParser.toXml('/path/to/save.xml', xmlAsObject);
});

XML Object structure

{
    name: '', //will be == '#text' if this node represent pure text
    attributes:[], 
    nodes:[], 
    parentNode: xmlObj, 
    value:'', //it only contains something if this node is a #text node
    selfclosing: false
};

Attributes structure

{
    name: '', 
    value: ''
};

API

toJs (pathToXml, callback[xmlObj])

Creates a XML Object from a file, I made it that way to be more memory efficient than loading it from a string. And I'm not doing this work with strings, fuck yah.

toXml (pathToSaveXml, xmlObj)

Saves the xmlObj as a xml. Dãã!

Latest patch notes

  • Fixed issue where the convertion of the XML Object to JSON would return an error about circular structure
  • Added methods "getNewNode" and "getNewAttribute" to the exports, so that they can be used to add new elements to the XML Object
  • Added methods to node: getAttribute, getAttributeValue, getChildByName, getChildsByName
  • Fixed bug with tag definitions parsing

License

Copyright (c) 2016 Ivan S. Cavalheiro Licensed under the MIT license