manoelcampos / xml2lua

XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables 🌖💱
MIT License
287 stars 73 forks source link

Missing attribute named 'n' in parse method #51

Closed slzhu closed 3 years ago

slzhu commented 3 years ago
local inspect         = require("inspect")
local xml2lua         = require("xml2lua")
local tree_handler    = require("xmlhandler.tree")

local message_handler = tree_handler:new()
local parser          = xml2lua.parser(message_handler)

local stanza          = [[<message><ext><from n='name1' res='res1'/></ext></message>]]

parser:parse(stanza)
print(inspect(message_handler.root.message))

It outputs: { ext = { from = { _attr = { res = "res1" } } } }.

But if I simply change the n to nd, it outputs as expected: { ext = { from = { _attr = { nd = "name1", res = "res1" } } } }

hyee commented 3 years ago

I ran into the similar issue, it fails to parse tag n. For example: <msg><n>abc</n></msg>