mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Add a test for Document.get with namespaces
This commit is contained in:
@@ -47,3 +47,18 @@ const doc = new libxmljs.Document();
|
||||
.node('sibling', 'with content!');
|
||||
|
||||
const {name, externalId, systemId} = doc.getDtd();
|
||||
|
||||
const xmlWithNs = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<root>' +
|
||||
'<child xmlns:a="http://test.com/test" foo="bar">' +
|
||||
'<a:grandchild baz="fizbuzz">grandchild content</a:grandchild>' +
|
||||
'</child>' +
|
||||
'<sibling>with content!</sibling>' +
|
||||
'</root>';
|
||||
|
||||
const xmlDocWithNs = libxmljs.parseXml(xmlWithNs);
|
||||
|
||||
// xpath queries
|
||||
const gchildWithNs = xmlDocWithNs.get('//a:grandchild', {"a": "http://test.com/test"})!;
|
||||
|
||||
console.log(gchildWithNs.text()); // prints "grandchild content"
|
||||
Reference in New Issue
Block a user