[xml] Using libxml2 to parse Wikipedia bot login results

Hi everyone.

I'm a noob learning C. C99, to be precise. I've decided to code a Wikipedia bot in C. I know it's probably not the best language to choose...

My code successfully logs in via the Wikimedia API. In order to do so, I need to parse this kind of result:

<?xml version="1.0"?><api><login result="Success" lguserid="14084680" lgusername="RichardcavellBot" lgtoken="b0aa68b61c803e96144d82e0f535d63b" cookieprefix="enwiki" sessionid="bb538415baebda74e35ff6262dc92e19" /></api>

All I really want is to pass the term "login result" to a function and get "Success" in reply, or indeed whatever else is in those quotes. At the moment I'm doing it using <string.h> and it works, but is probably not very future-proof nor very professional. Should I be using libxml? If so, how do I do it without getting bogged down in parsing an XML tree?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]