我不明白如何获取CDATA的内容,我
NSString* htmlString = [self getnerateFormattedString:details];
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.myWebsite.com"]];
-(NSString*) getnerateFormattedString:(TrackDetails*) details
{
NSString* htmlString = @"";
htmlString = @"<html><head><title><style type=\"text/css\">a {color: red}</style>";
htmlString = [htmlString stringByAppendingString:@"</title></head><body style='background-color: transparent;'> "];
if (atrackDetails.trackTitle != nil)
{
htmlString = [htmlString stringByAppendingString:@"<div align='center' >"];
htmlString = [htmlString stringByAppendingString:@"<font size='4'>"];
htmlString = [htmlString stringByAppendingString:details.trackTitle];
htmlString = [htmlString stringByAppendingString:@"</b></font></div><br>"];
}
htmlString = [htmlString stringByAppendingString:@"<table width=300px cellpadding=5 cellspacing=5 border=0 align='center' height=10px> "];
像这样我使用loadHTMLString加载。但我不知道如何让CDATA内容加载webView。
请帮助我, 谢谢, Madan Mohan。
答案 0 :(得分:0)
你有带HTML内容的cdata代码
解析Xml时,如下所示,
dataString = [dataString stringByAppendingString:@“”];
dataString = [dataString stringByAppendingString:@“带有html内容的cdata代码,例如”
dataString = [dataString stringByAppendingString:@“”];
你会得到这个 - &gt;只有你可以传递给它在webview中可以显示的方法的Html代码。 将此字符串传递给webView中的loadHTMLString方法