libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit ed631099da00ece0d1ddf058f06d753200748470
parent 6f1d7f31a73848a9dfb762b6a2fe408e3024e407
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Thu, 26 Mar 2020 09:10:00 +0100

Solve XPath problem with namespaces.

Diffstat:
Mnexus/src/test/kotlin/XPathTest.kt | 37+++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/nexus/src/test/kotlin/XPathTest.kt b/nexus/src/test/kotlin/XPathTest.kt @@ -2,6 +2,7 @@ package tech.libeufin.nexus import org.junit.Test import org.w3c.dom.Document +import org.w3c.dom.Node import tech.libeufin.util.XMLUtil @@ -10,13 +11,34 @@ class XPathTest { @Test fun pickDataFromSimpleXml() { val xml = """ - <root> + <root xmlns="foo"> <node>lorem ipsum</node> </root>""".trimIndent() - val doc: Document = tech.libeufin.util.XMLUtil.parseStringIntoDom(xml) - val nodeSlashes = XMLUtil.evalXpath(doc, "/root/node/text()") - println(nodeSlashes?.nodeValue) - val nodeDoubleSlashes = XMLUtil.evalXpath(doc, "//node/text()") - println(nodeDoubleSlashes?.nodeValue) + val doc: Document = XMLUtil.parseStringIntoDom(xml) + val node = XMLUtil.evalXpath(doc, "/*[local-name()='root']") + assert(node != null) } -} -\ No newline at end of file +} + + + + + + + + + + + + + + + + + + + + + + +