You need to parse the xml file (extracted from the docx) with Lua. I tried luaxml but failed (or maybe failed), my luaxml does not see the structure with colons ... A conditional example from zbstudio in the attachment: 
1 answer
Here it is possible so with levels and nodes and without recursion:
local str_xml = [[<?xml version="1.0" encoding="utf-8" ?> <w:document xmlns:w="....."> <w:body att="xxx"> <w:p att="yyy1"> <w:r att="zzz"> <w:t>Hello world!</w:t> </w:r> </w:p> <w:p att="yyy2"> </w:p> </w:body> </w:document> ]] require 'luaxml' local xtable = xml.eval(str_xml) if type(xtable)=='table' then for i=1,#xtable do local nodeL1 = xtable[i] if nodeL1[0] == 'w:body' then print(nodeL1.att) local level1=1 while nodeL1[level1] do if nodeL1[level1][0] == 'w:p' then print("L1",nodeL1[level1].att) local nodeL2 = nodeL1[level1] local level2=1 while nodeL2[level2] do if nodeL2[level2][0] == 'w:r' then print("L2",nodeL2[level2].att) local nodeL3 = nodeL2[level2] local level3=1 while nodeL3[level3] do if nodeL3[level3][0] == 'w:t' then print("L3",nodeL3[level3][1]) --- и т.д. end level3=level3+1 end end level2=level2+1 end end level1=level1+1 end end end end You can also do it with a recursive call function if you wish.
|