Today is a good day to code

64-bit, NSXMLDocument, and XCode

Posted: December 31st, 1969 | Author: | Filed under: Uncategorized | No Comments »

64-bit, NSXMLDocument, and XCode

Picture of IrvinRecently, I have been working with many large XML files. Mostly I am transforming the XML to more presentation friendly XHTML, but I picked up a fair speed boost when I switched to compiling it for 64-bit. The problem was that I started having some intermittent problems with certain XML documents.

It was strange, sometimes it wouldn't find XML below a certain tag. It would treat the NSXMLElement or NSXMLNode as all text. So I could do an

NSLog(@”value: %@”,element);

and I would see my content, but when I tried to parse out attributes or anything, I would get nothing. If I set breakpoints and tried to use the Cocoa debugger, the result was nothing as well. Basically it would tell me that the element had no children, and the name attribute was invalid.

I finally traced the difference to one document encoding as UTF-8, that one worked well, and the other document as being US-ASCII. That one didn't work. I wasted an entire day troubleshooting it, and nothing worked. Finally I started eliminating the custom adjustments I had made to my environment. When I switched from GCC 64-bit to GCC 32-bit everything started working fine. I wonder if there is some problem with 64-bit integers and libxml2.2, or whether it is just that NSXMLDocument hasn't been brought over to 64-bit. Either way, if you see this problem, make sure you are compiling for 32-bit.