【问题标题】:Parsing HTML content解析 HTML 内容
【发布时间】:2014-02-05 13:01:10
【问题描述】:

我正在解析链接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>";
        },

【问题讨论】:

    标签: html ios parsing xpath tfhpple


    【解决方案1】:

    借助“zootreeves / Objective-C-HMTL-Parser”https://github.com/zootreeves/Objective-C-HMTL-Parser,我能够阅读 HTML 标记的具体细节。

    只是想发布答案,因为它可能对其他人有帮助!。

    【讨论】:

      【解决方案2】:

      【讨论】:

      • 之前我尝试使用 NSXML 进行解析,但无法获取特定 HTML 标记的内容。我使用'zootreeves / Objective-C-HMTL-Parser'进行解析。谢谢。
      • 可以使用 NSXML - 你只需要读取子节点。
      • 您能否分享一个示例或链接来解释这些步骤。我想解析链接 feedproxy.google.com/~r/NDTV-Tech/~3/YNW1kE-FDv0/story01.htm> 并获取“HeadContent_FullstoryCtrl_fulldetails”的内容。谢谢。
      猜你喜欢
      • 1970-01-01
      • 2021-12-30
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 2014-04-11
      • 2017-10-28
      • 2014-10-18
      • 1970-01-01
      相关资源
      最近更新 更多