我在JSON中有HTML标记和实体,我不知道如何在我的应用中显示它。我尝试删除新行,我尝试解码html实体,但没有任何效果。
以下是我拥有的JSON示例:
{"Jobdesc":[{"jobid":"12281","job_title":"IOS Developer for Noida Location Job","job_desc":"<p><strong>Job Description</strong><br />
Dear Candidate&nbsp;<br />
I have an opening for IOS Developer for Noida Location for leading IT company. pli\ease find the JD below-<br />
JOB DESCRIPTION :-<br />
Industry :- IT&nbsp;<br />
Experience :- Min 1 Year<br />
Position :- IOS Developer<br />
Location :- Noida<br />
&nbsp;<br />
<strong>Job Responsibility :-&nbsp;</strong><br />
&nbsp;<br />
Design and build advanced applications for the iOS platform<br />
Collaborate with cross-functional teams to define, design, and ship new features</p>
<p>Working experience in iOS development<br />
Have published one or more iOS apps in the app store<br />
A deep familiarity with Objective-C and Cocoa Touch<br />
Experience working with iOS frameworks such as Core Data, Core Animation, Core Graphics and Core Text<br />
&nbsp;If you are interested in the above mentioned JD kindly share your resume with me and contact me on :-<br />
&nbsp;<br />
Thanks And Regards<br />
Pal Mittal<br />
Contact no :- 9200272001<br />
Email ID :- parul@india-shine.in<br />
&nbsp;<br />
&nbsp;<br />
Functional Area: Web / Mobile Technologies&nbsp;<br />
Industry: IT - Software&nbsp;<br />
Skills: IOS ipad&nbsp;<br />
Other Skills: IOS Developer Iphone Developer IOS Application Developer iphone Application Developer iphone<br />
&nbsp;<br />
Recruiter details&nbsp;<br />
Company Name: Employment Solution<br />
Email: pal@ishine.in<br />
Telephone: 9200272001</p>
","job_role":"IOS Developer","job_exp":"1-4 year","job_education":"MCA","job_location":"Delhi","job_address":"Delhi","j ob_company_name":"India Shine Employment Solution","job_company_url":"www.india- shine.in","job_company_email":"kumar178dilip@gmail.com","job_status":""}]}
答案 0 :(得分:2)
实际上有两种方法
方法1
<强>代码强>
@interface NSAttributedString (HTML)
+ (instancetype)attributedStringWithHTMLString:(NSString *)htmlString;
@end
@implementation NSAttributedString (HTML)
+ (instancetype)attributedStringWithHTMLString:(NSString *)htmlString
{
NSDictionary *options = @{ NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute :@(NSUTF8StringEncoding) };
NSData *data = [htmlString dataUsingEncoding:NSUTF8StringEncoding];
return [[NSAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
}
@end
<强>用法强>
NSString *cleanString = [[NSAttributedString attributedStringWithHTMLString:question.title] string];
方法2
结帐NSString category for XMLEntities。有解码XML实体(包括所有HTML字符引用),编码XML实体,剥离标记以及从字符串中删除换行符和空格的方法:
- (NSString *)stringByStrippingTags;
- (NSString *)stringByDecodingXMLEntities; // Including all HTML character references
- (NSString *)stringByEncodingXMLEntities;
- (NSString *)stringWithNewLinesAsBRs;
- (NSString *)stringByRemovingNewLinesAndWhitespace;
答案 1 :(得分:0)
您可以使用UIWebView并将其显示如下:
postman.setGlobalVariable("IID", Math.floor(Math.random() * 100));