{"name":"xpath","version":"0.0.29","description":"DOM 3 XPath implemention and helper for node.js.","engines":{"node":">=0.6.0"},"author":{"name":"Cameron McCormack"},"contributors":[{"name":"goto100"},{"name":"James Rishe"}],"dependencies":{},"devDependencies":{"xmldom":"^0.1.19"},"typings":"./xpath.d.ts","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/goto100/xpath.git"},"main":"./xpath.js","keywords":["xpath","xml"],"license":"MIT","gitHead":"ca98ad4e3db89ed6338e3b771898d196a654d6bd","bugs":{"url":"https://github.com/goto100/xpath/issues"},"homepage":"https://github.com/goto100/xpath#readme","_id":"xpath@0.0.29","_nodeVersion":"13.9.0","_npmVersion":"6.13.7","dist":{"integrity":"sha512-W6vSxu0tmHCW01EwDXx45/BAAl8lBJjcRB6eSswMuycOVbUkYskG3W1LtCxcesVel/RaNe/pxtd3FWLiqHGweA==","shasum":"eabccf418b2b9af4d67d8f1e5cc4f3b9562bce93","tarball":"http://registry-npm.ywwl.com/xpath/download/xpath-0.0.29.tgz","fileCount":13,"unpackedSize":232982,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfP7ozCRA9TVsSAnZWagAA23IP/jGK5jDCkWtSuclxFP1k\nIo+N+DtzW1ljwojkWI/5IdtI7z64RHiDjaYeM0i0muRz6pewK2bjHATdZ7tq\nkK0J7YeOGcZTZRHcs3LeeMNjx5UslK4OfdoukPc1hQubPbvFdcgOFozoVG/P\nG7oUzNZDL8ReFo2NRuIk+EyF69mXC/tg+SbGyVW5oC46cWqYD4Slw1RcJKdk\nFPYSAAWdjPV9XhGOFUHDhNvrVEMGOYSvn+lLhPPNoPYshNtE7YD5fLraLZDp\npxkZ7jiB9CRKTYF7gp77+cobyHz4CMZuVbH1ES4h9S5Exdcw94saWC1qvl1f\n8rAIpOLumTd3ISjzoOqOhmiAlNMM+Ig5BP88guJEG6h6U85nCNocuIIIkS65\nUcwMsZT1Inm1kNxjkr28P5Ry3w4WpTIbftvs1Z8Eq2DoaeRPycrm8R1YX6wW\nAauTW4XGSuTpZdDBxzTcQAiuaJjbY7HbeUEWShn4NjHrxBZygXAr90212h7Z\nD35bA5bAXgWpay/WJZuMIz8JGt7fku/h7I7Yb2w6QP6pOykjvqNrjwHT4iop\n1JpVhtrvEyInGLvsuyplpxxP/Q6mOpZ9TXMvmpgOHtlM/jvadJ7K1bWJRvLz\nLtd/U3Y9EjlLocLPiOfctEeYv5noctxE2PSYb7Yj/EytSji99c9zIrTNvG7Q\n6gFf\r\n=mQl5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfBF1PF1tlZdUSMgCARdQQkqBaDUQkMNBtcLEWXM2SDwIgRIhS23CRsHH9LtNmSTcj7U5jpvOgRPxd/l12wy5MoI0="}],"size":39082,"noattachment":false,"key":"/xpath/-/xpath-0.0.29.tgz"},"maintainers":[{"name":"goto100","email":"goto100@gmail.com"},{"name":"jlrishe","email":"jrishe@gmail.com"}],"_npmUser":{"name":"jlrishe","email":"jrishe@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xpath_0.0.29_1598011954653_0.7297344501928391"},"_hasShrinkwrap":false,"readme":"## xpath\r\nDOM 3 XPath 1.0 implemention and helper for JavaScript, with node.js support.\r\n\r\nOriginally written by Cameron McCormack ([blog](http://mcc.id.au/xpathjs)).\r\n\r\nAdditional contributions from  \r\nYaron Naveh ([blog](http://webservices20.blogspot.com/))  \r\ngoto100  \r\nThomas Weinert  \r\nJimmy Rishe  \r\nand [others](https://github.com/goto100/xpath/graphs/contributors)\r\n\r\n## Install\r\nInstall with [npm](http://github.com/isaacs/npm):\r\n\r\n    npm install xpath\r\n\r\nxpath is xml engine agnostic but we recommend [xmldom](https://github.com/xmldom/xmldom):\r\n\r\n    npm install @xmldom/xmldom\r\n\r\n## API Documentation\r\n\r\nCan be found [here](https://github.com/goto100/xpath/blob/master/docs/xpath%20methods.md). See below for example usage.\r\n\r\n## Your first xpath:\r\n`````javascript\r\nvar xpath = require('xpath');\r\nvar dom = require('@xmldom/xmldom').DOMParser;\r\n\r\nvar xml = \"<book><title>Harry Potter</title></book>\";\r\nvar doc = new dom().parseFromString(xml, 'text/xml');\r\nvar nodes = xpath.select(\"//title\", doc);\r\n\r\nconsole.log(nodes[0].localName + \": \" + nodes[0].firstChild.data);\r\nconsole.log(\"Node: \" + nodes[0].toString());\r\n`````\r\n➡\r\n\r\n    title: Harry Potter\r\n    Node: <title>Harry Potter</title>\r\n\r\n### Alternatively\r\n\r\nUsing the same interface you have on modern browsers ([MDN])\r\n\r\n`````javascript\r\nvar node = null;\r\nvar xml = \"<book author='J. K. Rowling'><title>Harry Potter</title></book>\";\r\nvar doc = new dom().parseFromString(xml, 'text/xml');\r\nvar result = xpath.evaluate(\r\n    \"/book/title\",            // xpathExpression\r\n    doc,                        // contextNode\r\n    null,                       // namespaceResolver\r\n    xpath.XPathResult.ANY_TYPE, // resultType\r\n    null                        // result\r\n);\r\n\r\nnode = result.iterateNext();\r\nwhile (node) {\r\n    console.log(node.localName + \": \" + node.firstChild.data);\r\n    console.log(\"Node: \" + node.toString());\r\n\r\n    node = result.iterateNext();\r\n}\r\n`````\r\n➡\r\n\r\n    title: Harry Potter\r\n    Node: <title>Harry Potter</title>\r\n\r\n## Evaluate string values directly:\r\n`````javascript\r\nvar xml = \"<book><title>Harry Potter</title></book>\";\r\nvar doc = new dom().parseFromString(xml, 'text/xml');\r\nvar title = xpath.select(\"string(//title)\", doc);\r\n\r\nconsole.log(title);\r\n`````\r\n➡\r\n\r\n    Harry Potter\r\n\r\n## Namespaces\r\n`````javascript\r\nvar xml = \"<book><title xmlns='myns'>Harry Potter</title></book>\";\r\nvar doc = new dom().parseFromString(xml, 'text/xml');\r\nvar node = xpath.select(\"//*[local-name(.)='title' and namespace-uri(.)='myns']\", doc)[0];\r\n\r\nconsole.log(node.namespaceURI);\r\n`````\r\n➡\r\n\r\n    myns\r\n\r\n## Namespaces with easy mappings\r\n`````javascript\r\nvar xml = \"<book xmlns:bookml='http://example.com/book'><bookml:title>Harry Potter</bookml:title></book>\"\r\nvar select = xpath.useNamespaces({\"bookml\": \"http://example.com/book\"});\r\n\r\nconsole.log(select('//bookml:title/text()', doc)[0].nodeValue);\r\n`````\r\n➡\r\n\r\n    Harry Potter\r\n\r\n## Default namespace with mapping\r\n`````javascript\r\nvar xml = \"<book xmlns='http://example.com/book'><title>Harry Potter</title></book>\"\r\nvar select = xpath.useNamespaces({\"bookml\": \"http://example.com/book\"});\r\n\r\nconsole.log(select('//bookml:title/text()', doc)[0].nodeValue);\r\n`````\r\n➡\r\n\r\n    Harry Potter\r\n\r\n## Attributes\r\n`````javascript\r\nvar xml = \"<book author='J. K. Rowling'><title>Harry Potter</title></book>\";\r\nvar doc = new dom().parseFromString(xml, 'text/xml');\r\nvar author = xpath.select1(\"/book/@author\", doc).value;\r\n\r\nconsole.log(author);\r\n`````\r\n➡\r\n\r\n    J. K. Rowling\r\n\r\n[MDN]: https://developer.mozilla.org/en/docs/Web/API/Document/evaluate\r\n\r\n## License\r\nMIT\r\n","publish_time":1598011954849,"_cnpm_publish_time":1598011954849,"dist-tags":{"latest":"0.0.36"}}