Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'nsxpath'

  • Loading branch information...
commit 51b202057508b3885e5fc3425b6bf179b34b1407 2 parents 1f11c30 + a30cd8d
@ncb000gt ncb000gt authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 test/namespace.js
View
36 test/namespace.js
@@ -138,3 +138,39 @@ module.exports.nested = function(assert) {
assert.done();
};
+
+module.exports.xmlns = function(assert) {
+ var str = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><div>BACON</div><div>ROCKS</div><p>WUT?</p></body></html>';
+ var doc = libxml.parseXmlString(str);
+ //throw because we don't specify the url
+ //assert.throws(function() {
+ //doc.find('//xmlns:div');
+ //});
+ var divs = doc.find('//xmlns:div', 'http://www.w3.org/1999/xhtml');
+ assert.equal(divs.length, 2);
+
+ var div = doc.get('//xmlns:div', 'http://www.w3.org/1999/xhtml');
+ var exp = doc.root().child(2).child(0);
+ assert.ok(div != null);
+ assert.ok(exp != null);
+ assert.equal(div.toString(), exp.toString());
+ assert.done();
+}
+
+module.exports.custom_ns = function(assert) {
+ var str = '<html xmlns:bacon="http://www.example.com/fake/uri"><head></head><body><div>BACON</div><div>ROCKS</div><p>WUT?</p></body></html>';
+ var doc = libxml.parseXmlString(str);
+ //throw because we don't specify the url
+ //assert.throws(function() {
+ //doc.find('//xmlns:div');
+ //});
+ var divs = doc.find('//bacon:div', 'http://www.example.com/fake/uri');
+ assert.equal(divs.length, 2);
+
+ var div = doc.get('//bacon:div', 'http://www.example.com/fake/uri');
+ var exp = doc.root().child(2).child(0);
+ assert.ok(div != null);
+ assert.ok(exp != null);
+ assert.equal(div.toString(), exp.toString());
+ assert.done();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.