2012-02-24 68 views
-1

這可能是一個簡單的問題,但我無法從下面的字符串中獲取確切的數據。 以下數據我想提取,但我無法做到這一點。 1.說明 2.當文字 3.凡文本 4.單擊此處鏈接轉換HTML字符串

如何轉換這種客觀C.

<p> 
    <a href="http://feedads.g.doubleclick.net/~a/uD33rOAaHkAZywKvO6ntrkv_ETU/0/da"> 
     <img src="http://feedads.g.doubleclick.net/~a/uD33rOAaHkAZywKvO6ntrkv_ETU/0/di" border="0" ismap="true"></img> 
    </a> 
<br/> 
    <a href="http://feedads.g.doubleclick.net/~a/uD33rOAaHkAZywKvO6ntrkv_ETU/1/da"> 
     <img src="http://feedads.g.doubleclick.net/~a/uD33rOAaHkAZywKvO6ntrkv_ETU/1/di" border="0" ismap="true"></img> 
    </a> 
</p> 


<p> 
    <a href="http://mumbai.burrp.com/events/little-theatre-ncpa_semshook_nariman-point_mumbai/19313517316"> 
     <img src="/images/evt/c/6/[email protected]_2wat_1_300.jpg"/> 
    </a> 
</p>     


<p> 
    Tenzin is a Tibetan born and raised in India. Yearning to explore his true homeland, he impulsively hops on his motorcycle and embarks on a personal quest: to find his identity and discover the indescribable beauty and wonders of his magnificent homeland. But Tibet is a nation under siege from a repressive regime. While Tenzin encounters friendship, camaraderie and even love along the way, he cannot escape the horrors of a political world he wants no part of. Looking only for the way to peace, both within himself and for the land he loves, Tenzin must find the courage to pursue the truth, even if it means facing terrible dangers to find his Semshook. 
<strong>Language</strong>: Hindi, English, Tibetan Film with English subtitles 
<strong>Directed by</strong>: Siddharth Anand Kumar 
<strong>Cast</strong>: Tenzin Younden, Tenzin Choedon and Tensin Woebhum 
</p> 

<p> 
    <strong>When:</strong> Friday Feb, 24 
</p>  

<p> 
    <strong>Where:</strong> Little Theatre (NCPA), Nariman Poin 
</p> 

<p> 
    <a href="http://mumbai.burrp.com/events/index.html">More events</a> in Mumbai 
</p> 

<p> 
    <a href="http://mumbai.burrp.com/events/date/this-weekend">Click Here</a> to view more events happening <strong>this weekend</strong> in Mumbai 
</p> 

我已經使用這個代碼,但是這給了我平淡文本,我想鏈接相關的文字意味着像文字和鏈接的組合。

NSScanner *theScanner; 
    NSString *text = nil; 
    theScanner = [NSScanner scannerWithString:html]; 

    while ([theScanner isAtEnd] == NO) { 

     [theScanner scanUpToString:@"<" intoString:NULL] ; 

     [theScanner scanUpToString:@">" intoString:&text] ; 

     html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""]; 
    } 
    // 
    html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 
    NSLog(@"html======================>%@",html); 
    return html; 

回答

0

使用XML解析和NSString方法的組合。

+0

請您簡單介紹一下或者提供一些代碼 – mashios 2012-02-24 07:09:44