From cda90e424674c41c3447d4ebc3709dd290ccf512 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 15 Nov 2025 19:38:12 +0800 Subject: add xpath support --- tests/modules/xml/test.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/modules/xml/test.lua') diff --git a/tests/modules/xml/test.lua b/tests/modules/xml/test.lua index 60d50d62a..21a4e7745 100644 --- a/tests/modules/xml/test.lua +++ b/tests/modules/xml/test.lua @@ -124,3 +124,22 @@ function test_scan_stop(t) t:are_equal(xml.text_of(found), "NSPrincipalClass") end +function test_find_xpath(t) + local doc = xml.decode([[ + + + foo + bar + + + + +]]) + local second = xml.find(doc, "root/items/item[2]") + t:are_equal(second.attrs.id, "b") + local descendant = xml.find(doc, "//item[@id='c']") + t:are_equal(descendant.attrs.id, "c") + local value = xml.find(doc, "//value[text()='bar']") + t:are_equal(xml.text_of(value), "bar") +end + -- cgit v1.3.1