I'm really need help with parsing XML by TBXML. I created a demo project with a view has a button,when users press this button, I just call TBXML parsing function from another class. Im doing this to test my TBXMLParsing function works correctly or not. And it works pretty well in my demo project.
Finally, after I tested it, I copy and paste the function into my real project which has a button in first view, when I click on that button then it calls TBXMLParsing function. In other words, it is basically same as demo project. However, TBXMLParsing function doesn't work. It cant traverse thru all elements.
Do you have any ideas? Thanks for helping me.
Update: It is working if I simulate my app on real device, but it does not traverse thru the XML if I simulate it on simulator. It is so weird. However it does work on simulator if I create new project. Thus, there must be something that in my app that prevent parser XML.
Any ideas? Thank you
Update2:
NSData *data = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:@"http://dl.dropbox.com/u/37064335/ex.xml"]];
TBXML *tbxml = [[TBXML alloc] initWithXMLData:data];
[data release];
TBXMLElement *root = tbxml.rootXMLElement;
// if root element is valid
if (root) {
NSLog(@"root =%s",root->name);
This is the part messed me up. I tested in demo app, Nslog root=GetUserAccountsRespond However in my app Nslog root= (nil-nothing printed out). Both projects are basically the same.
I would check that the XML document you are trying to parse is loaded correctly before passing it onto TBXML to decode. It sound to me like there is a problem with the loading code on the sim. Try outputting the file contents to the log to verify its correct.
Ok Here is solution for anyone that might has same problem as me. The problem was because when I Analyzed(shift+command+B) my project, xcode detected some "Semantic Issue" in TBXML.m. Then I just followed xcode's guide to change "=" to "==" in 3 places where it said "Process XML"(line258,311,and458) in TBXML.m. Thus TBXML does not work, because it cant process input XML. This problem drove me crazy for 2days. Thanks Tom Bradley for TBXML