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

xmlchecker

v0.1.0

Published

Checking XML syntax of files using pegjs grammar, pretty print XML files and concert XML into JSON

Downloads

5,110

Readme

xmlChecker

Validating the syntax of a xml text

xmlChecker.js (and xmlCheckerModule.js) is PEG.js grammar to validate a string against the XML syntax. xmlChecker.js doesn't validate the string against a XSD schema. xmlChecker.js can used to check a file on the fly, e.g. while editing the file in a web browser at development time.

xmlPrettifier.js (and xmlPrettifierModule.js) converts a string in the XML format to a prettified version of the string in XML.

xml2json.js (and xml2jsonModule.js) converts a string in the xml format to a json data structure using the same grammar as the xmlChecker.js .

Features

  • check the basic syntax according to the specification at [w3c](http://www.w3.org/TR/xml
  • check if start and end tag matches
  • check if namespace prefixes are declared
  • easy integrateable in JavaScript code on client (xmlChecker.js for web browser) and server side (xmlCheckerModule.js for node.js or use mpn install xmlChecker)
  • easy extendable
  • pretty print xml code
  • converting xml strings to JSON data structures

JSON conventions for XML content

  • each XML element is a dictionary entry containing an array with attributes, elements, text values and comments
  • element names are directly taken over including the full namespace
  • each XML attribute is a dictionary entry conating an array of values
  • attribute names are prefixed using a "@" and includes the full nampespace
  • namespaces are prefixing the name of an element or attribute and are URL-encoded enclosed by two underlines
  • the text value entries have the special name "#text"
  • the cdata value entries have the special name "#cdata"
  • comment entries have the special name "#comment"

Getting started

Just include the xmlChecker.js in your client code

<script src="/js/xmlChecker.js"/>

or import the module in node.js using npm install xmlChecker

var xmlChecker = require('xmlChecker');

and use it

try
	xmlChecker.check(source)
catch error
	alert("XML Parser: " + error.name + " at " + error.line + "," + error.column + ": " + error.message);

For more examples see the code in examples.

Development

Just to use the library copy the file xmlChecker.js to your preferred location.

To modify the grammar you need to install PEG.js by

npm install pegjs

and compile it, e.g. using

./pegjs.sh