Very simple question but giving me hard time, I want to replace " to \\" in my entire xml file. I tried but don't know how to do it.
My try :
escapedXMLString = [xml stringByReplacingOccurrencesOfString:@""" withString:@"\""];
of course above line won't even compile, as I am escaping the double quote. So is there any work around?
您需要\\来转义“在查找字符串中的”和替换中的\\中的\\“。
escapedXMLString = [xml stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
If you need to generate this literal for something more involved you might consider using a tool like this:
http://www.freeformatter.com/java-dotnet-escape.html#ad-output
to accomplish the work for you.
See also this answer .
试试[xml stringByReplacingOccurrencesOfString:@"\\"" withString:@"\\\\\\""]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.