Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua - Parsing XML from a URL

I want to parse this XML http://steamcommunity.com/id/GreenMarineValve?xml=1 with Lua 5.1, there are some libraries like LuaXML but they do not support parsing from the URL.

Would you give me a link to a library to do that if there is any or some advice to achieve my goal?

-

More details for those who have experience with Steam's Web API, I basically want to convert "customURL" to Steam Community ID (steamID64), but I see there is no other way doing it without parsing that XML file, I could parse it from the URL if it was JSON format instead of XML.

Is there an API I'm missing which will take the customURL as a parameter and return the communityID ? Some related links to WebAPI: https://developer.valvesoftware.com/wiki/Steam_Web_API https://partner.steamgames.com/documentation/webapi

like image 755
Fiat Pax Avatar asked May 13 '26 13:05

Fiat Pax


1 Answers

If you know how to get the contents of a URL into a Lua string, then getting the fields you want is simple:

function get(data,name)
    return data:match("<"..name..">(.-)</"..name..">")
end

-- assumes C contains the downloaded contents
print(get(C,"customURL"))
print(get(C,"steamID64"))
like image 80
lhf Avatar answered May 16 '26 06:05

lhf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!