Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DaveGee

macrumors 6502a
Original poster
Jul 25, 2001
677
2
Sad but true...

While NSXMLDocument works fine and dandy in the iPhone simulator Apple pulled the rug out from under us and DOES NOT include NSXMLDocument in the actual iPhone APIs (when compiling for the device)....

So in short anyone have any cleaver ways to work around this issue?

The stuff I need/rely on most are:

NSXMLDocument objectsForXQuery and NSXMLNode

The objectsForXQuery is a real necessity and I'm afraid any workaround will be a pain to develop...

Anyone got any ideas?

Thanks in advance!!

Dave
 

ayasin

macrumors 6502
Jun 26, 2008
318
0
I got bit by this today as well. Fortunately for my purposes manually dropping the stuff into a dictionary won't be too bad. That probably won't help you though...sorry.
 

DaveGee

macrumors 6502a
Original poster
Jul 25, 2001
677
2
I got bit by this today as well. Fortunately for my purposes manually dropping the stuff into a dictionary won't be too bad. That probably won't help you though...sorry.

Is there an easy way to do this?

I'm still somewhat green when it comes to Cocoa... the XML I get is quite basic really.... No deeply nested arrays of arrays of arrays or anything like that... its more like this:

Code:
<list>

<device>
<name code="143">thename</name>
<id>theid</id>
<statis>thestatus</status>
</device>

<device>
<name code="122">thename</name>
<id>theid</id>
<statis>thestatus</status>
</device>

<device>
<name code="153">thename</name>
<id>theid</id>
<statis>thestatus</status>
</device>

</list>

So it looks really simple but I don't wanna even think about trying to parse it with the limited string manipulation available in Cocoa.. OH WHAT I WOULD GIVE FOR REGEX!!! I could turn that XML into a tab delimited list of items with one simple REGEX call... but alas Apple doesn't believe it that either... Really odd if you ask me, I can't think of another programming environment that doesn't offer the developer quick and easy access to regex in some form or another...

If anyone has any idea -- even 'messy ones' I'm all ears... I *so* wanna get this app running on my iPod touch... Apple sure pulled a fast one on us by not including NSXML in the device (but allowing it in the simulator)...

Oh any before anyone asks if I can modify the 'source' that is providing me the XML.. that's a *no go* since its a hardware device running microcode that in turn does lots of stuff... one of which is providing SOAP access to people wanting to get data from it. (in short, a very close system).

Thanks

Dave
 

DaveGee

macrumors 6502a
Original poster
Jul 25, 2001
677
2
If you don't need to create any XML documents but just read them, then you can use NSXMLParser.
There is also this which has been created to mimic NSXML in terms of reading XML.

Thanks and yea I found out that even tho just about all of NSXML was yanked Apple did leave us with NSXMLParser and quite frankly I took to it immediately (and I'm still in the 'advanced-beginner' stage of knowing Cocoa)... I even wrote my code in such a way that it handles 3 different XML sources so thats kinda nice... Yea it's probably not the *right way* to do things but it does the job quite nicely for me so I'm happy... :)

Dave
 

arashpayan

macrumors newbie
Jan 14, 2009
1
0
If you want a simplified NSXMLDocument replacement on iPhone, check out this little library I threw together for a project I recently finished:
http://arashpayan.com/projects/APXML

It doesn't handle all the fanciness of XML, but it allows you to load up XML documents into a DOM, and even create documents to write out to XML.

-Arash
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.