Answer the question
In order to leave comments, you need to log in
[[+content_image]]
Unable to spread xml?
good afternoon, help parse xml
code written in LUA
require('xmlreader')
local xml =[[
<?xml version="1.0" encoding="utf-8"?>
<recognitionResults success="1">
<variant confidence="0">нет спасибо</variant>
<variant confidence="0.1">нет спасибо</variant>
</recognitionResults>
]]
local r = assert(xmlreader.from_string(xml))
while (r:read()) do
local leadingws = (' '):rep(r:depth())
if (r:node_type() == "element") then
io.write(("%s%s:"):format(leadingws, r:name()))
while (r:move_to_next_attribute()) do
io.write((' %s=%q'):format(r:name(), r:value()))
end
io.write('\n')
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question