Skip to content

Commit c5f7db0

Browse files
committed
sample: add sample for "Document:create_namespace()"
1 parent 20dae55 commit c5f7db0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sample/document-create-namespace.lua

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env luajit
2+
3+
local xmlua = require("xmlua")
4+
5+
local document = xmlua.XML.build({"root"})
6+
local namespace =
7+
document:create_namespace("http://www.w3.org/1999/xhtml",
8+
"xhtml")
9+
local root = document:root()
10+
root:set_namespace(namespace)
11+
print(namespace:href(), namespace:prefix(), document:to_xml())
12+
--"http://www.w3.org/1999/xhtml",
13+
--"xhtml",
14+
--<?xml version="1.0" encoding="UTF-8"?>
15+
--<xhtml:root/>
16+

0 commit comments

Comments
 (0)