0

リンクhttp://feedproxy.google.com/~r/NDTV-Tech/~3/YNW1kE-FDv0/story01.htmを解析して、「HeadContent_FullstoryCtrl_fulldetails」HTML タグからコンテンツを取得しています。私は TFHpple を使用し、//*[@id='HeadContent_FullstoryCtrl_fulldetails'] を使用して xpath パーサーを 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>";
        },
4

2 に答える 2

0

「zootreeves / Objective-C-HMTL-Parser」https://github.com/zootreeves/Objective-C-HMTL-Parserの助けを借りて、HTML タグの特定の詳細を読み取ることができます。

他の人に役立つかもしれないので、答えを投稿したかっただけです!.

于 2014-01-20T09:23:39.050 に答える
0

NSXMLParser がこれを処理します: https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/Classes/NSXMLParser_Class/Reference/Reference.html

于 2014-01-16T14:59:50.817 に答える