如何将CDATA内容获取到iPhone SDK中的UIWebView中?
我不明白如何获取 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。
请帮我, 谢谢你, 马丹·莫汉。
I am not understanding how to get the content of CDATA, I
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> "];
Like this I am loading using loadHTMLString. But I don't know how to get CDATA Content to load webView.
Please Help Me,
Thank you,
Madan Mohan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有带有html内容的cdata代码
当你像这样解析Xml时,如下所示,
dataString =[dataString stringByAppendingString:@""];
dataString=[dataString stringByAppendingString:@"带有html内容的cdata代码例如"
dataString =[dataString stringByAppendingString:@""];
你会得到这个-->您只能将 Html 代码传递给可以在 Web 视图中显示的方法。
将此字符串传递给 webView 中的 loadHTMLString 方法
you have cdata code with html content
When you parse the Xml like this, shown below,
dataString =[dataString stringByAppendingString:@""];
dataString=[dataString stringByAppendingString:@"cdata code with html content for example"
dataString =[dataString stringByAppendingString:@""];
You will get this --> Only Html code that u can pass to method which it can dispaly in webview.
Pass this string to loadHTMLString method in webView