Fleegix.js
Simple. Useful. JavaScript.

Plugins: fleegix.xml


A compact XML parser that deserializes an XML document into an JavaScript Object hierarchy.

Download fleegix.xml (3KB)

fleegix.xml.parse

Syntax

fleegix.xml.parse(xmlDoc, [tagName]);

Parameters

xmlDoc (Object) -- DOM-compatible XML Document object.

tagName (String) -- Tag name to expedite parsing a list of same-named tags into an Array. If you pass this parameter, the parser will use getElementsByTagName on the XML document, and parse the resulting nodeList instead of the entire document.

Description

Parses an XML document into a JavaScript Object. Same-named tags at the same document hierarchy are parsed into an Array.

Examples

function handleUserList(xml) {
  // Get the array of <USER> tags
  var users = fleegix.xml.parse(xml, 'USER');
  var userCount = users.length;
  var firstUserUsername = users[0].username;
}

fleegix.xhr.doGet(handleUserList, 'user_list.rbx', 'xml');