Closed scambra closed 4 years ago
Yes, the XML parser wasn't really that great. I don't quite remember why I didn't search for a better one! It does make sense to replace the current xml parser. Please go ahead and provide a PR!
PS I appreciate the contributions! I'm happy to see that it has some use for others.
Should I copy files from xml2lua, or just use it and user would install xml2lua and aws-sdk-lua?
I would suggest that you copy xml2lua.lua and XmlParser.lua and add a note here: https://github.com/britzl/aws-sdk-lua#third-party-code-used
xml.parse returns a table where each tag is a table with keys label and xarg, which is not easy to process. For example, rest_xml is not processing correctly parsed xml, and it passes data.Message as error message, but data.Message is nil.
I got this xml returned by AWS:
And it's parsed into this table:
So rest_xml methods should look for table containing 'Message' label, and return first element, because data.Message is nil.
I have replaced utils/xml.lua with https://github.com/manoelcampos/xml2lua, using xmlhandler.tree and returns this table:
I guess this structure is similar to structure returned by json handlers. And rest_xml may pass data.Error.Message.
I don't know what should be second parameter for callback, currently is data.__type which has no value in xml, and I don't know what value is in json handler.
Would you agree replacing current xml parser with xml2lua?