Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including xtraverse with all npm packages installed. Try it out:

var xtraverse = require("xtraverse")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

xtraverse v0.1.0

Wrapper for simplifying XML traversal.


Simplified traversal and building of an XML DOM.

This module provides a jQuery-like wrapper, but geared for traversing and manipulating an XML DOM, as opposeed to an HTML DOM. The API aims to be compatible with Strophe.js' Builder and Less-Than XML. The underlying DOM is W3C standard, provided by XMLDOM.


$ npm install xtraverse


Parse XML

var xml = fs.readFileSync('feed.xml', 'utf8');
var feed = XT(xml);

Traverse XML

for (var link = feed.children().first('link'); link.length > 0; link ='link')) {
for (var entry = feed.children().first('entry'); entry.length > 0; entry ='entry')) {
  console.log('Entry: ' + entry.children('title').text());

Build XML

var feed = XT('<feed xmlns=""/>')
  .c('title').t('Example Feed').up()
  .c('link', { href: '' })
  .c('entry').c('title').t('Atom-Powered Robots Run Amok').up().up()
  .c('entry').c('title').t('Today I Ate Pancakes');


$ npm install
$ npm test


Build Status David DM



The MIT License

Copyright (c) 2013 Jared Hanson <>

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free