Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
46 lines (35 loc) · 895 Bytes

File metadata and controls

executable file
·
46 lines (35 loc) · 895 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env luajit
local xmlua = require("xmlua")
local document = xmlua.XML.parse([[
<xml>
<header>
<title>This is test</title>
</header>
<contents>
<sub1>sub1</sub1>
<sub2>sub2</sub2>
<sub3>sub3</sub3>
</contents>
</xml>
]])
-- Insert a node
local node_set = document:search("//title")
-- <title>This is test</title>
local sub1 = document:search("//xml/contents/sub1")[1]
-- <sub1>sub1</sub1>
node_set:insert(sub1)
print(node_set:to_xml())
-- <title>This is test</title><sub1>sub1</sub1>
-- Insert a node with position
local node_set = document:search("//xml/contents/*")
-- <sub1>sub1</sub1>
-- <sub2>sub2</sub2>
-- <sub3>sub3</sub3>
local title = document:search("//title")[1]
-- <title>This is test</title>
node_set:insert(1, title)
print(node_set:to_xml())
-- <title>This is test</title>
-- <sub1>sub1</sub1>
-- <sub2>sub2</sub2>
-- <sub3>sub3</sub3>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.