{
"_args": [
[
{
"raw": "xmldoc@^0.4.0",
"scope": null,
"escapedName": "xmldoc",
"name": "xmldoc",
"rawSpec": "^0.4.0",
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/react-native"
]
],
"_from": "xmldoc@>=0.4.0 <0.5.0",
"_id": "xmldoc@0.4.0",
"_inCache": true,
"_location": "/xmldoc",
"_nodeVersion": "4.1.1",
"_npmUser": {
"name": "nfarina",
"email": "nfarina@gmail.com"
},
"_npmVersion": "2.14.4",
"_phantomChildren": {},
"_requested": {
"raw": "xmldoc@^0.4.0",
"scope": null,
"escapedName": "xmldoc",
"name": "xmldoc",
"rawSpec": "^0.4.0",
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"_requiredBy": [
"/react-native"
],
"_resolved": "https://registry.npmjs.org/xmldoc/-/xmldoc-0.4.0.tgz",
"_shasum": "d257224be8393eaacbf837ef227fd8ec25b36888",
"_shrinkwrap": null,
"_spec": "xmldoc@^0.4.0",
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/react-native",
"author": {
"name": "Nick Farina",
"email": "nfarina@gmail.com",
"url": "http://nfarina.com"
},
"bugs": {
"url": "https://github.com/nfarina/xmldoc/issues"
},
"contributors": [
{
"name": "Nick Farina",
"email": "nfarina@gmail.com"
}
],
"dependencies": {
"sax": "~1.1.1"
},
"description": "A lightweight XML Document class for JavaScript.",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "d257224be8393eaacbf837ef227fd8ec25b36888",
"tarball": "https://registry.npmjs.org/xmldoc/-/xmldoc-0.4.0.tgz"
},
"gitHead": "48c1b3b4414fa612e5eff005346d6787ab441b98",
"homepage": "https://github.com/nfarina/xmldoc#readme",
"license": {
"type": "MIT",
"url": "https://raw.github.com/nfarina/xmldoc-js/master/LICENSE"
},
"main": "./index",
"maintainers": [
{
"name": "nfarina",
"email": "nfarina@gmail.com"
}
],
"name": "xmldoc",
"optionalDependencies": {},
"readme": "\n## Introduction\n\n`xmldoc` lets you parse XML documents with ease. It's a pure-JavaScript, one-file XML document class with a single dependency on the excellent [`sax`][sax] parser.\n\nFor more on why I wrote this class, see the [blog post][blog].\n\n [blog]: http://nfarina.com/post/34302964969/a-lightweight-xml-document-class-for-nodejs-javascript\n\n## Installation\n\n npm install xmldoc\n\nOr just download the repository and include it in your `node_modules` directly. Or just download the [single JS file][blob]!\n\n [blob]: https://github.com/nfarina/xmldoc/blob/master/lib/xmldoc.js\n\n## Usage\n\n```js\nvar xmldoc = require('../lib/xmldoc');\n\nvar document = new xmldoc.XmlDocument(\"xml\");\n\n// do things\n```\n\n## Classes\n\nThe primary exported class is `XmlDocument`, which you'll use to consume your XML text. `XmlDocument` contains a hierarchy of `XmlElement` instances representing the XML structure.\n\nBoth `XmlElement` and `XmlDocument` contain the same members and methods you can call to traverse the document or a subtree.\n\n## Members\n\n* `name` - the node name, like \"tat\" for ``. XML \"namespaces\" are ignored by the underlying [sax-js](https://github.com/isaacs/sax-js) parser, so you'll simply get \"office:body\" for ``.\n* `attr` - an object dict containing attribute properties, like `bookNode.attr.title` for ``.\n* `val` - the string \"value\" of the node, if any, like \"world\" for `world`.\n* `children` - an array of `XmlElement` children of the node.\n* `firstChild`, `lastChild` - pretty much what it sounds like; null if no children\n* `line`, `column`, `position`, `startTagPosition` - information about the element's original position in the XML string.\n\nEach member defaults to a sensible \"empty\" value like `{}` for `attr`, `[]` for `children`, and `\"\"` for `val`.\n\n## Methods\n\nAll methods with `child` in the name operate only on direct children; they do not do a deep/recursive search.\n\nIt's important to note that `xmldoc` is designed for when you know exactly what you want from your XML file. For instance, it's great for parsing API responses with known structures, but it's not great at teasing things out of HTML documents from the web.\n\nIf you need to do lots of searching through your XML document, I highly recommend trying a different library like [node-elementtree](https://github.com/racker/node-elementtree).\n\n### eachChild(func)\n\nSimilar to [underscore's][underscore] `each` method, it will call `func(child, index, array)` for each child of the given node.\n\n### childNamed(name)\n\nPass it the name of a child node and it will search for and return the first one found, or `undefined`.\n\n### childrenNamed(name)\n\nLike `childNamed` but returns all matching children in an array, or `[]`.\n\n### childWithAttribute(name,value)\n\nSearches for the first child with the given attribute value. You can omit `value` to just find the first node with the given attribute defined at all.\n\n### descendantWithPath(path)\n\nSearches for a specific \"path\" using dot notation. Example:\n\n```xml\n\n \n George R. R. Martin\n ...\n \n ...\n\n```\n\nIf you just want the `` node and you have the `XmlElement` for the `` node, you can say:\n\n```js\nvar nameNode = bookNode.descendantWithPath(\"author.name\"); // return node\n```\n\n### valueWithPath(path)\n\nJust like `descendantWithPath`, but goes deeper and extracts the `val` of the node. Example:\n\n```js\nvar authorName = bookNode.valueWithPath(\"author.name\"); // return \"George R. R. Martin\"\n```\n\nYou can also use the `@` character to request the value of a particular _attribute_ instead:\n\n```js\nvar authorIsProper = bookNode.valueWithPath(\"author.name@isProper\"); // return \"true\"\n```\n\nThis is not [XPath][]! It's just a thing I made up, OK?\n\n### toString([options])\n\nThis is just an override of the standard JavaScript method, it will give you a string representation of your XML document or element. Note that this is for debugging only! It is not guaranteed to always output valid XML.\n\nThe default implementation of `toString()`, that is, the one you get when you just `console.log(\"Doc: \" + myDoc)` will pretty-print the XML with linebreaks and indents. You can pass a couple options to control the output:\n\n```js\nxml.toString({compressed:true}) // strips indents and linebreaks\nxml.toString({trimmed:true}) // trims long strings for easier debugging\nxml.toString({preserveWhitespace:true}) // prevents whitespace being removed from around element values\n```\n\nPutting it all together:\n\n```js\nvar xml = \"looooooong value\";\nconsole.log(\"My document: \\n\" + new XmlDocument(xml).toString({trimmed:true}))\n```\n\nPrints:\n\n My Document:\n \n loooooooo…\n \n\n## Feedback\n\nFeel free to file issues or hit me up on [Twitter][twitter].\n\n [underscore]: http://underscorejs.org\n [XPath]: http://en.wikipedia.org/wiki/XPath\n [twitter]: http://twitter.com/nfarina\n [sax]: https://github.com/isaacs/sax-js\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git://github.com/nfarina/xmldoc.git"
},
"scripts": {},
"version": "0.4.0"
}