]> git.sesse.net Git - vlc/commitdiff
Add function to add a children map to an xml table. (children_map[tagname] is an...
authorAntoine Cellerier <dionoea@videolan.org>
Sun, 14 Feb 2010 23:39:52 +0000 (00:39 +0100)
committerAntoine Cellerier <dionoea@videolan.org>
Sun, 14 Feb 2010 23:40:26 +0000 (00:40 +0100)
share/lua/modules/simplexml.lua

index 5d0d60f5bd979cc99514e564a09d1ea590fbd3d0..bda68a4869a3a3097c550470319b45a4eb0da48b 100644 (file)
@@ -93,3 +93,16 @@ end
 function parse_string(str)
     return parsexml(vlc.memory_stream(str))
 end
+
+function add_name_maps(tree)
+    tree.children_map = {}
+    for _, node in pairs(tree.children) do
+        if type(node) == "table" then
+            if not tree.children_map[node.name] then
+                tree.children_map[node.name] = {}
+            end
+            table.insert(tree.children_map[node.name], node)
+            add_name_maps(node)
+        end
+    end
+end