From fc97008aabfb6aeab26fecc4f31c1d020a750f45 Mon Sep 17 00:00:00 2001 From: rycornell Date: Tue, 28 Aug 2018 20:56:34 -0400 Subject: [PATCH] Add a test for Document.get with namespaces --- types/libxmljs/libxmljs-tests.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/libxmljs/libxmljs-tests.ts b/types/libxmljs/libxmljs-tests.ts index 367d74c69d..72c480614e 100644 --- a/types/libxmljs/libxmljs-tests.ts +++ b/types/libxmljs/libxmljs-tests.ts @@ -47,3 +47,18 @@ const doc = new libxmljs.Document(); .node('sibling', 'with content!'); const {name, externalId, systemId} = doc.getDtd(); + +const xmlWithNs = '' + + '' + + '' + + 'grandchild content' + + '' + + 'with content!' + + ''; + +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" \ No newline at end of file