Parsing Xml/json to understand the structure of the Xml/json in advance, for the mobile phone may be more lightweight JSON, but with Java as a service side may be more inclined to use XML, the introduction of Tbxml official example.
<?XML version= "1.0"?><authors> <authorname= "J.K. Rowling"> < Booktitle= "Harry Potter and the philosopher ' s Stone" Price= "119.99"> <Description>Harry Potter thinks he's an ordinary boy-until he's rescued from a beetle-eyed giant of a man, ENR Olls at Hogwarts School of Witchcraft and Wizardry, learns to play Quidditch and does battle in a deadly duel. </Description> </ Book> < Booktitle= "Harry Potter and the Chamber of Secrets" Price= "8.99"> <Description>When the Chamber of Secrets are opened again at the Hogwarts School for Witchcraft and Wizardry, second -year student Harry Potter finds himself in danger from a dark power that have once more been released on the school. </Description> </ Book> </author> <authorname= "Douglas Adams"> < Booktitle= "The Hitchhiker's Guide to the Galaxy" Price= "15.49"> <Description>Join Douglas Adams ' s hapless hero Arthur Dent as he travels the galaxy with his intrepid pal Ford Pre Fect, getting into horrible messes and generally wreaking hilarious havoc. </Description> </ Book> < Booktitle= "The Restaurant at the End of the Universe" Price= "14.36"> <Description>Arthur and Ford, having survived the destruction of Earth by surreptitiously hitching a ride on a Vogo N constructor ship, with been kicked off, the ship by its commander. Now they find themselves aboard a stolen improbability drive ship commanded by Beeblebrox, ex-president of the Imperial Ga Lactic government and full-time thief. </Description> </ Book> </author></authors>
The main data structures are
typedef struct _tbxmlelement { Span style= "color: #0000ff;" >char * name; char * text; Tbxmlattribute * FirstAttribute; struct _tbxmlelement * parentelement; struct _tbxmlelement * FirstChild; struct _tbxmlelement * Currentchild; struct _tbxmlelement * nextSibling; struct _tbxmlelement * previoussibling;} tbxmlelement;
struct _tbxmlattribute {char * name; Char * value; struct _tbxmlattribute * next;} Tbxmlattribute;
Reads an XML file or reads from an XML string or from NSData to
TBXML *tbxml = [[TBXML alloc] Initwithxmlfile:@ "books.xml"*tbxml = [[TBXML alloc] Initwithxmlfile:@ "books" fileextension:@ "xml"* Tbxml =*tbxml = [[Tbxml alloc] initwithxmldata:xmldata];