2012-02-24 17 views
-1

これは簡単な質問ですが、下の文字列から正確なデータを取得できません。 以下のデータを抽出したいが、これを行うことができない。 1.説明 2.ときにテキスト ここにテキスト 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> 

でこれを変換します3。テキスト、私はそのテキストに関連するリンクがテキストとリンクの組み合わせのように意味します。

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