lua-libxml icon indicating copy to clipboard operation
lua-libxml copied to clipboard

Function load not working

Open Lucky4Luuk opened this issue 7 years ago • 2 comments

Hey there,

I'm trying to use libxml to parse some XML (duh), but after calling require, it gives the following error: main.lua:19: attempt to call field 'load' (a nil value)

Here is a hastebin of my code, do you know what I'm doing wrong? https://hastebin.com/uxusipajub.lua

Thanks for looking,

Lucky4Luuk

Lucky4Luuk avatar Aug 04 '17 10:08 Lucky4Luuk

this library does not have a top level load method. It appears your error is coming from your main.lua line 19:

local xmldoc = libxml.load(data)

Instead, you have to create a DOMParser directly and parse an xml string. I believe it goes like this:

local libxml = require('xml.init')
local parser = libxml.dom.DOMParser()
local document = parser:parseFromString("<root><foo></foo></root>")

This library has not had much activity in some time and I have not made any significant updates in a while. May I ask where you found lua-libxml from?

rdlaitila avatar Aug 05 '17 06:08 rdlaitila

I found it on Love2d wiki among recommended libraries

EvGamer avatar Dec 27 '18 20:12 EvGamer