如何将CDATA内容获取到iPhone SDK中的UIWebView中?

发布于 2024-09-14 19:24:33 字数 1186 浏览 10 评论 0原文

我不明白如何获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬 2024-09-21 19:24:33

你有带有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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文