NSString to xml?
NSString to xml?
- Subject: NSString to xml?
- From: Gus Mueller <email@hidden>
- Date: Tue, 4 Feb 2003 19:45:31 -0800
I'm working with the WebServices stuff, and I noticed that when I add a NSString (among other objects) to
the WSMethodInvocationSetParameters function, it's not getting serialized... (ie, <'s turned into <'s)
ok, I can do that myself I guess... so I wrote a quick little function to do this, but for some reason it
gives me the creeps... surely there's an api out there that I'm missing that will do this for me, right?
Well, I've looked and I can't seem to find it.. has anyone got any suggestions?
And here's my quick little function that I was talking about-
NSString* escapeString(NSString* s) {
NSMutableString *ms = [NSMutableString string];
const char *temp = [s cString];
char c;
int i, len = [s cStringLength];
for (i=0; i<len; i++) {
c = temp[i];
if ((int)c > 127) // warning: comparison is always false due to limited range of data type
[ms appendString:[NSString stringWithFormat:@"&#%d;", c]];
else if (c == '&')
[ms appendString:@"&"];
else if (c == '<')
[ms appendString:@"<"];
else if (c == '>')
[ms appendString:@">"];
else
[ms appendString:[NSString stringWithFormat:@"%c", c]];
}
return ms;
}
thanks,
-gus
--
"Christmas means carnage!" -- Ferdinand, the duck
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.