2010-08-17 61 views
0

我不理解怎麼去CDATA的內容,我如何在iPhone SDK中將CDATA內容導入UIWebView?

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 Content加載webView。

請幫幫我, 謝謝, Madan Mohan。

回答

0

您有HTML內容CDATA代碼

當解析XML這樣,如下所示,

dataString = [dataString stringByAppendingString:@ 「」];

dataString = [dataString stringByAppendingString:@

dataString = [dataString stringByAppendingString 「與HTML內容例如CDATA代碼」:@ 「」];

你會得到這個 - >只有Html代碼,你可以傳遞給它可以在webview中顯示的方法。 將此字符串傳遞給webView中的loadHTMLString方法