-- TshwaneLex / TshwaneTerm/tlTerm sample Lua script. -- http://tshwanedje.com/ -- -- This sample demonstrates how to access 'text' nodes that form part of the PCDATA of an element. -- This sample requires use of the 'new Document Object Model' (TshwaneLex 4.1 or higher). -- Make sure we have a document open local Doc = tApp():GetCurrentDoc(); if Doc == nil then return "No document open"; end function Recurse(Node) -- Check if we have a 'text' node if Node:IsKindOfClass(NODE_TEXTNODE) then -- Typecast the node to a tcText local TextNode = tolua.cast(Node, "tcText"); -- Log the text value tLuaLog(TextNode:GetText()); end -- Recurse through child nodes if Node:GetNumChildren() > 0 then for i=0,Node:GetNumChildren()-1,1 do Recurse(Node:GetChild(i)); end end end -- Recurse through all nodes of the document tree Recurse(Doc:GetDocumentRoot()); return "Done";