Use of IOS Tbxml

Source: Internet
Author: User

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];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.