Try to use XPath for extracting values. For this case a simple query like this will give you a proper result - "//login/@result", or if results are already predefined you can eveen do it like this - "//login[@result='Success']" - if this query returns at least one element you are fine, otherwise you can assume it failed. etc.
On 28/02/2011 07:38 a.m., [email protected] wrote: > 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? > > Richard > > _______________________________________________ > xml mailing list, project page http://xmlsoft.org/ > [email protected] > http://mail.gnome.org/mailman/listinfo/xml _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
