TouchXML is a libxml API wrapper written in Objective-C and usually helps with all your project XML needs. While writing my post about parsing XML element attributes and putting up demo project I realized that I tend to forget how to add TouchXML to new project, so here goes step-by-step of that procedure:
1. Get TouchXML
You can find archives to download in touchcode project downloads . Go to TouchCode github page and download TouchXML archive and extract it anywhere you like. It’s common practice to keep such libraries and classes in Developer/ExtraLibs directory.
2. Enable libxml2 library
First things first, before we actually add TouchXML files, we need to do some project configuration changes, so our project could use libxml library.
1. Go to “Project -> Edit project settings”
2. Activate “Build” tab
3. Search for “Header search paths” setting and add /usr/include/libxml2 value to it

4. Search for “Other linker flags” setting and add -lxml2 value

P.s. notice that search function is really useful for finding settings you need faster.
3. Add TouchXML classes
1. Right click (option click) on your projects “Classes” folder and go to “Add -> Existing files…”
2. Navigate to the directory where extracted TouchXML is kept and browse deeper to “Common -> Source”. Select everything! And click “Add” obviously.

3. Confirm.

Now you should see a bunch of new files in your project. I usually group them by selecting files I wish to group and then selecting “Group” in context (right click/option click) menu.
4. Import TouchXML to your project
#import "TouchXML.h"
That is all the “magic” and you’re good to go. Since, I am not going to write about actually using TouchXML, you can see a nice working example in my previous post.
5. Common errors
Error: libxml/tree.h: No such file or directory
… and hundreds of something missing errors. It means that something went wrong with “Header search paths”. Maybe you didn’t added /usr/include/libxml2
or added incorrectly? Check it.
Error: “_xmlDocDumpFormatMemory”, referenced from:- [CXMLDocument description] in CXMLDocument.o
… and tens of errors like this. While errors by them selfs aren’t very expressive, they wish to inform you, that you did not added -lxml2 flag to “Other linker flags”
And that is all for now!
Tags: iphone-dev, libxml, TouchXML

Hi, i got this error,
“Error: libxml/tree.h: No such file or directory ” with 356 errors,
even after correctly added /usr/include/libxml2 to “Header search paths”. what to do?
hi, i follow everything above , but i got “Error: libxml/tree.h: No such file or directory” with 356 errors.help me.
I got the same problem too, but i found a solution is that…..
Please check your Configuration (Release / Debug) in Project Settings
It is damn shit that default is release mode …. but you compile in debug mode
Another possible solution for those having trouble:
instead of going to “Project -> Edit project settings” try making the changes in “Project -> Edit active target ” instead.
And do pay attention to the Configuration setting in the upper-left of the settings window. Change it to “All Configurations”.
It works very well except for one warning: CXMLDocument.m:229: warning: no ‘-_XMLStringWithOptions:appendingToString:’ method found
@masch – I just changed line 229 to be: [xmlString appendString:[root XMLStringWithOptions:options]];
And how do you install libxml2 if you don’t got it?
If you still get the libxml/tree.h errors you probably have devices specified under library search paths, like I had device and simulator (you may have one or the other). If you modify the library search path above these, it has no effect. You have to add it for each of these line items.
Also build->clean
I ran into the libxml/tree.h errors issue, and solved it for me. Remember that if you have multiple targets in your Xcode project, that you need to edit the configurations for all targets. For instance, I’ve got an App target, and a Tests target. I needed to add the /usr/include/libxml2 to the Header Search paths for “All configurations” in both of the targets.
you need to add libxml2 framework into the project too
HI…
great job you down…..
I configure but i got 24 errors in my application…..
_xmlDocSetRootElement
XmlNodeListGetString
xmlAddChild
xmlNewText…
xmlXPathFreeContext…
xmlReadMemory
xmlDocGetRootElement…….
……..
xmlFree
Great guide, good job!
Hi,
I have an error with TouchXML, Opening and Ending tag mismatch at the start of the CXMLDocument, and I haven’t even tried to parse it I, was just loading the data into the document and it crashed,
@Robert, did you find any solution for validating the xml content (Opening and Ending tag mismatch) using TouchXML . Please share..
archive missing
Both solitary cell phone number listed in the United States includes a full profile while features; names, age anthology, address, along with sexual category info.
The URL for the download isn’t working – looks like it needs updated to the new site. I was able to dig around and find a depreciated version of TouchXML for use.
pleasant post, i certainly love this url, proceed it
Everything is ok . What about the target .
Superb post, not often can I read such magnificance. Do you have any forums with similar content?
it works good well.thank u for given that one
i am getting tons of errors like that: “ARC forbids explicit message send to ‘autorelease’” and “autolrelease is unavailable…” – any ideas? does this API supports xcode 4.2?
@itai Please disable ARC in latest Xcode
Hi, I’m getting the same: “ARC forbids explicit message send to ‘autorelease’” issue. What should we do?
@alexz @itai Please disable ARC in latest Xcode
any chance to create a ARC enabled version?
My iOS app was just rejected by Apple for “using undocumented APIs.” They determined this based on the presence of a function called “elementWithName.” Quick search of my code yields this function name inside TouchXML. (1) Wow, F you Apple. (2) Perhaps you should change the name of the function? I will offer a patch on Github.
Works like a charm! Cheers for this.
Hi my app is crashing in iOS5
one of the error is this
CXMLDocument.m
function: initWithXMLString
EXC_BAD_ACCESS
Did anyone have the same issue ?
is there an update to touchXML to work with iOS5 ?
Thanks
very great post
Thanks for your introducing with TouchXML
How to parser XSD schema using Touch XML API
129
Station 1
Station 1
128
Station 2
Station 2
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"http://www.example.ae/",
@"tempuriSatellite",
nil];
// Set the resultNodes Array to contain an object for every instance of an node in our XSD feed
//resultNodes = [rssParser nodesForXPath:@"//GetStationsResult" error:nil];
resultNodes = [rssParser nodesForXPath:@"//tempuriSatellite:Stations" namespaceMappings:dict error:nil]
So, that’s how you add TouchXML to new project? I really don’t have much idea about these technical stuff but fortunately, you have posted images which made the process easier to understand and follow. Thanks! Will you be posting more guides like these? I’ll be looking forward to it.
Awesome article
well
Whenever you find yourself on the side of the majority, it is time to pause and reflect.
It isn’t whatever you pay a man, but what he costs you that counts.
zenwheel, wouldn’t that mean that XMLStringWithOptions would have infinite recursion? Not so sure that is a good solution… Why isn’t _XMLStringWithOptions defined? I see it is commented out in CXMLElement.m
i request my webservice url by asihttp and i get response of data in string format and i want to parse this xml string using touch xml so plz provide me touch xml example any url you have?
Hello there, You’ve performed a great job. I will certainly digg it and personally recommend to my friends. I am confident they will be benefited from this site.
Working…
I am curious to find out what blog system you have been working with? I’m having some small security problems with my latest blog and I’d like to find something more safeguarded. Do you have any solutions?Orange Roofing Contractors, 1010 N. Batavia St., #F2, Orange, CA 92867 – (714) 770-8684