2014-01-16 2 views
0

'HeadContent_FullstoryCtrl_fulldetails'HTML 태그에서 내용을 가져 오려면 http://feedproxy.google.com/~r/NDTV-Tech/~3/YNW1kE-FDv0/story01.htm 링크를 구문 분석하고 있습니다. TFHpple을 사용하고 xpath 파서를 HTML 요소에 // // [@ id = 'HeadContent_FullstoryCtrl_fulldetails'] 사용하여 가리키고 있습니다.HTML 컨텐트 구문 분석

이 응답은 아래 샘플에서와 같이 출력이있는 NSArray에 있습니다. 나는 'nodeContent'데이터 만 가져 와서 뉴스 세부 사항을 얻을 수있다.

<__NSArrayM 0x16d73950>(
{ 
    nodeAttributeArray =  (
       { 
      attributeName = id; 
      nodeContent = "HeadContent_FullstoryCtrl_fulldetails"; 
     }, 
       { 
      attributeName = class; 
      nodeContent = description; 
     } 
    ); 
    nodeChildArray =  (
       { 
      nodeChildArray =    (
           { 
        nodeContent = "The Lumia 1520 has two big things working against it, neither of \nwhich is a deal-breaker on its own, but when combined, make it a very \ninteresting product to review. First, it's a Windows Phone. While the \nplatform certainly does have its fans, there's no denying that it isn't \nas versatile as iOS and Android yet. As a person buying this phone, you \nwill have to put up with a number of limitations and frustrations \nbecause of its software. Second, it's huge. So-called \"phablets\" are big\n business, but not everybody wants a phone that can't fit in a pocket \nand be held in one hand. With that said, it's time to examine this phone\n on its own merits and see whether Nokia has managed to distinguish \nitself with a winner."; 
        nodeName = text; 
       } 
      ); 
      nodeName = p; 
      raw = "<p>The Lumia 1520 has two big things working against it, neither of \nwhich is a deal-breaker on its own, but when combined, make it a very \ninteresting product to review. First, it's a Windows Phone. While the \nplatform certainly does have its fans, there's no denying that it isn't \nas versatile as iOS and Android yet. As a person buying this phone, you \nwill have to put up with a number of limitations and frustrations \nbecause of its software. Second, it's huge. So-called \"phablets\" are big\n business, but not everybody wants a phone that can't fit in a pocket \nand be held in one hand. With that said, it's time to examine this phone\n on its own merits and see whether Nokia has managed to distinguish \nitself with a winner.</p>"; 
     }, 

답변

0
+1

이전 NSXML을 사용하여 구문 분석을 시도했지만 특정 HTML 태그의 내용을 가져올 수 없습니다. 구문 분석을 위해 'zootreeves/Objective-C-HMTL-Parser'를 사용했습니다. 감사. – user2071152

+0

NSXML을 사용하는 것이 가능합니다. 하위 노드 만 읽으면됩니다. – GuybrushThreepwood

+0

단계를 설명하는 예제 또는 링크를 공유해주십시오. 링크를 구문 분석하고 'HeadContent_FullstoryCtrl_fulldetails'의 콘텐츠를 가져오고 싶습니다. 감사. – user2071152