How to use Libxml in iOS

Source: Internet
Author: User
Tags map data structure

This article provides a quick overview of how to use Libxml in iOS
Mac OS version: 10.8.2
Xcode version: 4.5.1


1. Select Xcode Project Settings

2. Select target

3. Select Summary

4. Pull to Linked frameworks and Libraries , press the + button


Enter libxml and select libxml2, press the Add button


So you can see the libxml2.dylib in the project.


As in the first picture, the re-election to Build Setting

Pull down to find search Paths Find the Header search Paths

Open the Edit and press + and enter ${sdk_root}/usr/include/libxml2

This allows you to use Libxml in your Xcode project.

#include <libxml2/libxml/parser.h>

#include <libxml2/libxml/tree.h>

can include Libxml


[CPP]View Plaincopy
  1. < span class= "keyword" style= "margin:0px; padding:0px; Border:none; Color:rgb (0,102,153); Background-color:inherit; Font-weight:bold ">void  cblibxmlutility::savewithlibxml (Map<string,string>& data, const  string& filename)   
  2. {   
  3. // create xml document &NBSP;&NBSP;
  4. " 1.0 "
  5. " cloudboxroot "
  6. //set Root   
  7. Xmldocsetrootelement (Doc,root);
  8. for (map <string,string>::iterator iter = data.begin ();  iter != data.end ();  iter++)   
  9. " key: " <<iter->first<<
  10. Xmlnewtextchild (Root, NULL, Bad_cast (*iter). First.c_str (), Bad_cast (*iter). SECOND.C_STR ());
  11. }
  12. //save XML   
  13. int  nrel = xmlsavefile (Filename.c_str (), doc);   
  14. if   (nrel != -1)   
  15. " Create a xml: " <<NREL<< " bytes " <<ENDL;&NBSP;&NBSP;
  16. //debuglog (" create a xml %d bytes\n ", NRel); &NBSP;&NBSP;
  17. }
  18. //release   
  19. Xmlfreedoc (DOC);
  20. }

This piece of code is a simple example , the data in the map data structure is saved to XML.

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.