how to Send & symbol in xml body to server

旧巷老猫 提交于 2019-12-14 03:35:58

问题


I am trying to send the & symbol to the server in an XML body but only received a blank. I tried HTML code to send this also but in vain.


回答1:


You can create a category on NSString and then encode few characters that you cant send directly... few are implemented below:

@implementation NSString (URLEncoding)

- (NSString *) stringByUrlEncoding{
    return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,  (CFStringRef)self,  NULL,  (CFStringRef)@"!*'();:@&;=+$,/?%#[]",  kCFStringEncodingUTF8));
}

@end



回答2:


You can use the HTML entity:

&

For a full list of the HTML character entities see this.



来源:https://stackoverflow.com/questions/20094023/how-to-send-symbol-in-xml-body-to-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!