我想从数据库中检索html数据。我用这个代码解析,在iOS中解析HTML
-(NSString *)MultipleCharactersHTML:(NSString *)url
{
NSMutableURLRequest *request =[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:url]];
NSData *returnData = [ NSURLConnection sendSynchronousRequest:request returningResponse: nil error: nil ];
NSString *returnString = [[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding];
// NSLog(@"return string %@",returnString);
returnString=[returnString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
returnString=[returnString stringByReplacingOccurrencesOfString:@"\"<" withString:@"<"];
returnString=[returnString stringByReplacingOccurrencesOfString:@">\"" withString:@">"];
NSError *err = nil;
// NSLog(@"return string replaced %@",returnString);
// NSMutableArray *search = [NSJSONSerialization JSONObjectWithData:[returnString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&err];
// NSLog(@"search response %@",search);
return returnString;
}
但我无法检索数据...
我要设置这个数据作为htmlstring我的WebView ...任何人都请指导我..从数据库
数据将在这个格式...
<div class="layout-content-row content-header " style="display: inline-block; margin: 36px 0px 23px; height: 30px; padding: 0px 0px 10px; color: rgb(34, 34, 34); font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px; background-color: rgb(249, 249, 249);"><div class="layout-content-col span-9" style="float: left; margin-left: 0px; width: 520px; height: 1px;"><h1 itemprop="name" style="color: rgb(51, 51, 51); font-size: 34px; margin-top: 0px; margin-bottom: 0px; padding: 0px; line-height: 30px; width: 700px;">Creative Vision</h1></div><div class="paging-links layout-content-col span-4" itemscope="" itemtype="http://schema.org/SiteNavigationElement" style="float: left; margin-left: 20px; position: relative; height: 30px; width: 220px;"><a href="http://developer.android.com/design/index.html" class="prev-page-link" zh-tw-lang="上一堂課" zh-cn-lang="上一课" ru-lang="Предыдущий" ko-lang="이전" ja-lang="前へ" es-lang="Anterior" style="position: absolute; color: rgb(37, 138, 175); text-transform: uppercase; left: -15px;">PREVIOUS</a><a href="http://developer.android.com/design/get-started/principles.html" class="next-page-link" zh-tw-lang="下一堂課" zh-cn-lang="下一课" ru-lang="Следующий" ko-lang="다음" ja-lang="次へ" es-lang="Siguiente" style="position: absolute; color: rgb(37, 138, 175); text-transform: uppercase; right: 0px;">NEXT</a></div></div><span style="color: rgb(34, 34, 34); font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px; background-color: rgb(249, 249, 249);"></span><div id="jd-content" style="height: 790px; color: rgb(34, 34, 34); font-family: Roboto, sans-serif; font-size: 14px; line-height: 19px; background-color: rgb(249, 249, 249);"><div class="jd-descr" itemprop="articleBody" style="height: 725px;"><img src="http://developer.android.com/design/media/creative_vision_main.png" style="max-width: 100%; margin-bottom: 15px;"><div class="vspace size-1" style="height: 10px;"> </div><p itemprop="description" style="margin-bottom: 15px;">Starting with Ice Cream Sandwich, we focused the design of Android around these three overarching goals, which apply to our core apps as well as the system at large. As you work with Android, consider these goals.</p><div class="vspace size-1" style="height: 10px;"> </div><div class="layout-content-row" style="display: inline-block; margin-bottom: 10px;"><div class="layout-content-col span-4" style="float: left; margin-left: 0px; width: 220px;"><h4 style="line-height: 21px; margin: 0px 0px 12px;">Enchant me</h4><p style="margin-bottom: 15px;">Beauty is more than skin deep. Android apps are sleek and aesthetically pleasing on multiple levels. Transitions are fast and clear; layout and typography are crisp and meaningful. App icons are works of art in their own right. Just like a well-made tool, your app should strive to combine beauty, simplicity and purpose to create a magical experience that is effortless and powerful.</p></div><div class="layout-content-col span-5" style="float: left; margin-left: 20px; width: 280px;"><h4 style="line-height: 21px; margin: 0px 0px 12px;">Simplify my life</h4><p style="margin-bottom: 15px;">Android apps make life easier and are easy to understand. When people use your app for the first time, they should intuitively grasp the most important features. The design work doesn't stop at the first use, though. Android apps remove ongoing chores like file management and syncing. Simple tasks never require complex procedures, and complex tasks are tailored to the human hand and mind. People of all ages and cultures feel firmly in control, and are never overwhelmed by too many choices or irrelevant flash.</p></div><div class="layout-content-col span-4" style="float: left; margin-left: 20px; width: 220px;"><h4 style="line-height: 21px; margin: 0px 0px 12px;">Make me amazing</h4><p style="margin-bottom: 15px;">It's not enough to make an app that is easy to use. Android apps empower people to try new things and to use apps in inventive new ways. Android lets people combine applications into new workflows through multitasking, notifications, and sharing across apps. At the same time, your app should feel personal, giving people access to superb technology with clarity and grace.</p></div></div></div><div class="content-footer layout-content-row" itemscope="" itemtype="http://schema.org/SiteNavigationElement" style="display: inline-block; margin-bottom: 10px; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204); margin-top: 10px; padding-top: 10px; width: 760px;"><div class="paging-links layout-content-col col-10" style="float: left; margin-left: 0px; position: relative; height: 30px; display: inline; margin-right: 10px; width: 580px;"><a href="http://developer.android.com/design/get-started/principles.html" class="next-page-link" zh-tw-lang="下一堂課" zh-cn-lang="下一课" ru-lang="Следующий" ko-lang="다음" ja-lang="次へ" es-lang="Siguiente" style="position: absolute; color: rgb(37, 138, 175); text-transform: uppercase; right: 0px; left: 0px;">NEXT: DESIGN PRINCIPLES</a></div></div></div>
你能告诉我wats在我的文章中错了吗? – Tommy 2014-09-30 05:55:16