summaryrefslogtreecommitdiff
path: root/xmake/core/base/xml.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-15 19:42:39 +0800
committerruki <[email protected]>2025-11-15 19:42:39 +0800
commit0a21a3d88e6126b5bb691d393bfc7499810e3d4a (patch)
tree4cf545394fb010d40106759205528fe6a9c1d38a /xmake/core/base/xml.lua
parentcda90e424674c41c3447d4ebc3709dd290ccf512 (diff)
update tests
Diffstat (limited to 'xmake/core/base/xml.lua')
-rw-r--r--xmake/core/base/xml.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/xmake/core/base/xml.lua b/xmake/core/base/xml.lua
index 8bbdbb201..ab04c9696 100644
--- a/xmake/core/base/xml.lua
+++ b/xmake/core/base/xml.lua
@@ -26,7 +26,7 @@ local io = require("base/io")
local os = require("base/os")
local table = require("base/table")
--- XML node structure:
+-- XML node structure (mutable DOM-style tables):
-- {
-- name = "element-name" | nil (for non-element nodes)
-- kind = "element" | "text" | "comment" | "cdata" | "doctype" | "document"
@@ -38,12 +38,11 @@ local table = require("base/table")
--
-- Example:
-- local doc = xml.decode("<root id='1'><item>foo</item><!--note--></root>")
--- doc.kind == "element"
--- doc.attrs.id == "1"
--- xml.find(doc, "root/item").kind == "element"
--- xml.text_of(doc) == "" -- since root has no direct text nodes
--- doc.prolog[1].kind == "doctype" -- e.g. when document had <!DOCTYPE ...>
--- doc.children[2].kind == "comment" and doc.children[2].text == "note"
+-- local node = xml.find(doc, "root/item")
+-- node.attrs = {lang = "en"}
+-- node.children = {xml.text("bar")}
+-- xml.encode(doc) == '<root id="1"><item lang="en">bar</item><!--note--></root>'
+-- -- nodes are regular Lua tables, so modifying them in-place updates the DOM
--
-- decode entities