Skip to content

Commit 7c36ad4

Browse files
authored
Merge pull request #3 from thepeanutgalleryandco/master
Added ignore case functionality and catered for more Xpath expressions
2 parents c0d6696 + 5f46863 commit 7c36ad4

File tree

6 files changed

+362
-160
lines changed

6 files changed

+362
-160
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ Contributors
1919

2020
* blumf
2121
* Ivan Baidakou (basiliscos)
22+
* Rohan de Jongh (thepeanutgalleryandco)

Diff for: doc/us/index.html

+9-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ <h2><a name="overview"></a>Overview</h2>
6565

6666
<h2><a name="status"></a>Status</h2>
6767

68-
<p>Current version is 1.2. It was developed for Lua 5.1 based on <a href="http://www.keplerproject.org/luaexpat">
69-
LuaExpat</a> but also should work with Lua 5.2 and 5.3.
68+
<p>Current version is 1.3. It was developed for Lua 5.1 based on <a href="http://www.keplerproject.org/luaexpat">
69+
LuaExpat</a> but also should work with Lua 5.2, 5.3 and 5.4.
7070
</p>
7171

7272

@@ -78,6 +78,13 @@ <h2><a name="download"></a>Download</h2>
7878

7979
<h2><a name="history"></a>History</h2>
8080
<dl class="history">
81+
<dt><strong>Version 1.3</strong> [10/July/2024]</dt>
82+
<dd><ul>
83+
<li>Added ignore case functionality</li>
84+
<li>Added support for more XPath expressions that might be more complex</li>
85+
<li>Added comments in library</li>
86+
</ul></dd>
87+
8188
<dt><strong>Version 1.2</strong> [15/Mar/2015]</dt>
8289
<dd><ul>
8390
<li>Moved to github and a bit reogranized project structure</li>

Diff for: doc/us/manual.html

+41-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h2><a name="usage"></a>Usage</h2>
7373
require "luaxpath"
7474
local lom = require "lxp.lom"
7575

76-
xpath.selectNodes(lom.parse(xmlString),xpathExpression)
76+
xpath.selectNodes(lom.parse(xmlString),xpathExpression,ignoreCase)
7777
</pre>
7878

7979
<h2><a name="examples"></a>Examples</h2>
@@ -85,20 +85,54 @@ <h2><a name="examples"></a>Examples</h2>
8585
local xmlTest =
8686
[[
8787
&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
88-
&lt;root&gt;
89-
&lt;element id="1" name="element1"&gt;text of the first element&lt;/element&gt;
90-
&lt;element id="2" name="element2"&gt;
91-
&lt;subelement&gt;text of the second element&lt;/subelement&gt;
92-
&lt;/element&gt;
88+
&lt;root xmlns:test="https://test.test/"&gt;
89+
&lt;element id="1" name="element1"&gt;text of the first element&lt;/element&gt;
90+
&lt;element id="2" name="element2"&gt;
91+
&lt;subelement&gt;text of the second element&lt;/subelement&gt;
92+
&lt;/element&gt;
93+
&lt;test:newElement id="1" name="newElement"&gt;
94+
&lt;test&gt;text of the test element&lt;/test&gt;
95+
&lt;/test:newElement&gt;
9396
&lt;/root&gt;
9497
]]
9598

9699
-- get all elements
97100
xpath.selectNodes(lom.parse(xmlTest),'//element')
101+
98102
-- get the subelement text
99103
xpath.selectNodes(lom.parse(xmlTest),'/root/element/subelement/text()')
100-
-- get the first element
104+
105+
-- get the element by attribute id 1
101106
xpath.selectNodes(lom.parse(xmlTest),'/root/element[@id="1"]')
107+
108+
-- get node two by index
109+
xpath.selectNodes(lom.parse(xmlTest),'/root/element[2]')
110+
111+
-- get the first element node, with ignoring the case of element
112+
xpath.selectNodes(lom.parse(xmlTest),'/root/ELEMENT[1]',true)
113+
114+
-- get the newElement node and make use of the namespace in the tag name
115+
xpath.selectNodes(lom.parse(xmlTest),'/root/test:newElement')
116+
117+
-- get the node that has a child node that contains a tag name of subelement
118+
xpath.selectNodes(lom.parse(xmlTest),'//element[name="subelement"]')
119+
120+
-- get any node that has an attribute of test
121+
xpath.selectNodes(lom.parse(xmlTest),'//*/@test')
122+
123+
-- get the node by name
124+
xpath.selectNodes(lom.parse(xmlTest),'/root/element/node()')
125+
126+
-- get all child nodes of root
127+
xpath.selectNodes(lom.parse(xmlTest),'/root/*')
128+
129+
-- get all child nodes of root that contains an attribute of name which is equal to element
130+
xpath.selectNodes(lom.parse(xmlTest),'/root/element[contains(@name, "element")]')
131+
132+
-- get all element nodes that contains an attribute of name which starts with ele
133+
xpath.selectNodes(lom.parse(xmlTest),'/root/element[starts-with(@name, "ele")]')
134+
135+
102136
</pre>
103137

104138
<h2><a name="related_docs"></a>Related documentation</h2>

Diff for: rockspecs/luaxpath-1.2-4.rockspec renamed to rockspecs/luaxpath-1.3-0.rockspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package = "luaxpath"
2-
version = "1.2-4"
2+
version = "1.3-0"
33
source = {
44
url = "git://github.com/basiliscos/lua-xpath",
5-
tag = "v1.2.4",
5+
tag = "v1.3.0",
66
}
77
description = {
88
summary = "Simple XPath implementation in the Lua programming language.",

0 commit comments

Comments
 (0)