after a HTTP Post I retrieve an xml response like the following:
<result value="OK">
<user id="1">
<name>admin</name>
<rank>0</rank>
<picture_count>0</picture_count>
<comment_count>0</comment_count>
<has_profile>1</has_profile>
</user>
</result>
I’d like to extract the user ID, but I don’t know how to do this.
I tried with GDataXML Parser, because this is already integrated in my project, but
I don’t know how to get a value inside a html tag.
I hope you can help me. If there is no solution with XMLParser, would you recommend regular expressions? In this case, I would appreciate a solution for the regex expression, I’m not very good at this 🙂
Thanks in advance.
This is the code I use to retrieve the user attribute. It works.
The file test.xml is the same that you retrieve from the xml response. So you need to change the second line of this snippet of code. Maybe you can call
initWithDatamethod of classNSData.You can put this code where you want. Maybe you can create an other class that works as a centralized parser. Hope it helps
EDIT
Put these two lines before for instruction.
The explanation is quite simple. With
doc.rootElementyou retrieve the entire xml document, from<result>to</result>