local errorManager = require("errorManager") local function parseTag(str) local tag = { attributes = {} } tag.name = str:match("<(%w+)") for k,v in str:gmatch('%s(%w+)="([^"]-)"') do tag.attributes[k] = v end return tag end local function parseXML(self, xmlString) local stack = {} local root = {children = {}} local current = root local inCDATA = false local cdataContent = "" for line in xmlString:gmatch("[^\r\n]+") do line = line:match("^%s*(.-)%s*$") self.basalt.LOGGER.debug("Parsing line: " .. line) if line:match("^$") and inCDATA then inCDATA = false current.content = cdataContent elseif inCDATA then cdataContent = cdataContent .. line .. "\n" elseif line:match("^<[^/]") then local tag = parseTag(line) tag.children = {} tag.content = "" table.insert(current.children, tag) if not line:match("/>$") then table.insert(stack, current) current = tag end elseif line:match("^ 0 then createElements(node, element, scope) end end end end createElements(tree, self, scope) return self end return { BaseElement = BaseElement, Container = Container }