xml2lua
xml2lua copied to clipboard
Creating a DOM tree is missing XML declaration
trafficstars
Any XML declaration gets lost when parsing XML. Also, a ROOT type node is never created when using the DOM handler. As I understand it, the first tree node should be of type ROOT and when present should have the XML declaration as a child node under the DECL type. The first start element would then be the second child. This is easy to fix in xmlhandler/dom.lua in the function dom:decl() by adding: if self.root == nil then self.root = self.current end before or after the table.insert.
On reflection, I think it is even better to always have a ROOT node in the DOM handler, so that top-level comments are also preserved as its children. This can be achieved by setting root=curent in the init() function.