xmlom
Tiny XML Object Model
Last updated 4 years ago by potch .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install xmlom 
SYNC missed versions from official npm registry.

xmlom - a tiny XML object model

Greenkeeper badge

Usage

xmlom.parseString(str)

Parse an XML String.

Returns a Promise which resolves to a Document.

var xmlom = require('xmlom');
xmlom.parseString('<res><foo>bar</foo></res>').then(function (doc) {
  doc.find('foo').value; // "bar"
}).catch(function (error) {
  // parsing is hard
});

Document

Top-level result of parseString.

Document.root

The document-level Node of the XML Document

Document.find(nodeName)

Locate all nodes with named nodeName

Returns an Array of all matching Nodes.

Is an alias of Document.root.find.

Node

An element in the XML document.

Node.name

The name of the Node. e.g. <foo> would return "foo".

Node.value

A concatenated string of all the direct CDATA children of this Node.

Node.parent

This Node's parent Node. If this is the root Node, then null.

Node.children

An Array of the Node's children.

Node.attrs

An Object containing each of the Node's attributes as keys.

// <foo bar="baz">
node.attrs.bar; // "baz"

Node.comment

The text of any commments directly preceding the Node:

/* <!-- This is a comment -->
   <foo>bar</foo> */
node.comment; // "This is a comment"

Node.find(nodeName)

Locate all child Nodes named nodeName

Returns an Array of all matching Nodes.

Node.parents(nodeName)

Locate all Nodes in the Node's parent tree named nodeName.

Current Tags

  • 3.3.2                                ...           latest (a year ago)

17 Versions

  • 3.3.2                                ...           a year ago
  • 3.3.1                                ...           2 years ago
  • 3.3.0                                ...           2 years ago
  • 3.2.5                                ...           3 years ago
  • 3.2.4                                ...           3 years ago
  • 3.2.3                                ...           3 years ago
  • 3.2.2                                ...           3 years ago
  • 3.2.1                                ...           3 years ago
  • 3.2.0                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.2.1                                ...           3 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |