久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <bdo id='atRmb'></bdo><ul id='atRmb'></ul>
      <tfoot id='atRmb'></tfoot>

    1. <small id='atRmb'></small><noframes id='atRmb'>

      <legend id='atRmb'><style id='atRmb'><dir id='atRmb'><q id='atRmb'></q></dir></style></legend>
      <i id='atRmb'><tr id='atRmb'><dt id='atRmb'><q id='atRmb'><span id='atRmb'><b id='atRmb'><form id='atRmb'><ins id='atRmb'></ins><ul id='atRmb'></ul><sub id='atRmb'></sub></form><legend id='atRmb'></legend><bdo id='atRmb'><pre id='atRmb'><center id='atRmb'></center></pre></bdo></b><th id='atRmb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='atRmb'><tfoot id='atRmb'></tfoot><dl id='atRmb'><fieldset id='atRmb'></fieldset></dl></div>

        使用 HTMLAgilityPack 僅提取頁面文本

        extracting just page text using HTMLAgilityPack(使用 HTMLAgilityPack 僅提取頁面文本)
        <tfoot id='00oAW'></tfoot>

        1. <legend id='00oAW'><style id='00oAW'><dir id='00oAW'><q id='00oAW'></q></dir></style></legend>
          • <bdo id='00oAW'></bdo><ul id='00oAW'></ul>

                  <tbody id='00oAW'></tbody>
                <i id='00oAW'><tr id='00oAW'><dt id='00oAW'><q id='00oAW'><span id='00oAW'><b id='00oAW'><form id='00oAW'><ins id='00oAW'></ins><ul id='00oAW'></ul><sub id='00oAW'></sub></form><legend id='00oAW'></legend><bdo id='00oAW'><pre id='00oAW'><center id='00oAW'></center></pre></bdo></b><th id='00oAW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='00oAW'><tfoot id='00oAW'></tfoot><dl id='00oAW'><fieldset id='00oAW'></fieldset></dl></div>

                  <small id='00oAW'></small><noframes id='00oAW'>

                  本文介紹了使用 HTMLAgilityPack 僅提取頁面文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  好的,所以我對 HTMLAgilityPack 中使用的 XPath 查詢真的很陌生.

                  Ok so i am really new to XPath queries used in HTMLAgilityPack.

                  讓我們考慮這個頁面 http://health.yahoo.net/articles/healthcare/what-your-favorite-flavor-says-about-you.我想要的是只提取頁面內容而不是其他內容.

                  So lets consider this page http://health.yahoo.net/articles/healthcare/what-your-favorite-flavor-says-about-you. What i want is to extract just the page content and nothing else.

                  為此,我首先刪除腳本和樣式標簽.

                  So for that i first remove script and style tags.

                  Document = new HtmlDocument();
                          Document.LoadHtml(page);
                          TempString = new StringBuilder();
                          foreach (HtmlNode style in Document.DocumentNode.Descendants("style").ToArray())
                          {
                              style.Remove();
                          }
                          foreach (HtmlNode script in Document.DocumentNode.Descendants("script").ToArray())
                          {
                              script.Remove();
                          }
                  

                  之后我嘗試使用//text() 來獲取所有文本節點.

                  After that i am trying to use //text() to get all the text nodes.

                  foreach (HtmlTextNode node in Document.DocumentNode.SelectNodes("http://text()"))
                          {
                              TempString.AppendLine(node.InnerText);
                          }
                  

                  但是,我不僅得到了文本,而且還得到了許多/r/n 字符.

                  However not only i am not getting just text i am also getting numerous /r /n characters.

                  在這方面我需要一些指導.

                  Please i require a little guidance in this regard.

                  推薦答案

                  如果你認為 scriptstyle 節點只有孩子的文本節點,你可以使用這個XPath 表達式獲取不在 scriptstyle 標記中的文本節點,這樣您就無需事先刪除節點:

                  If you consider that script and style nodes only have text nodes for children, you can use this XPath expression to get text nodes that are not in script or style tags, so that you don't need to remove the nodes beforehand:

                  //*[not(self::script or self::style)]/text()
                  

                  您可以使用 XPath 的 normalize-space() 進一步排除純空格的文本節點:

                  You can further exclude text nodes that are only whitespace using XPath's normalize-space():

                  //*[not(self::script or self::style)]/text()[not(normalize-space(.)="")]
                  

                  或更短的

                  //*[not(self::script or self::style)]/text()[normalize-space()]
                  

                  但您仍然會得到可能有前導或尾隨空格的文本節點.這可以按照@aL3891 的建議在您的應用程序中處理.

                  But you will still get text nodes that may have leading or trailing whitespace. This can be handled in your application as @aL3891 suggests.

                  這篇關于使用 HTMLAgilityPack 僅提取頁面文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)

                1. <legend id='40l5D'><style id='40l5D'><dir id='40l5D'><q id='40l5D'></q></dir></style></legend>
                          <bdo id='40l5D'></bdo><ul id='40l5D'></ul>
                          <i id='40l5D'><tr id='40l5D'><dt id='40l5D'><q id='40l5D'><span id='40l5D'><b id='40l5D'><form id='40l5D'><ins id='40l5D'></ins><ul id='40l5D'></ul><sub id='40l5D'></sub></form><legend id='40l5D'></legend><bdo id='40l5D'><pre id='40l5D'><center id='40l5D'></center></pre></bdo></b><th id='40l5D'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='40l5D'><tfoot id='40l5D'></tfoot><dl id='40l5D'><fieldset id='40l5D'></fieldset></dl></div>

                          <small id='40l5D'></small><noframes id='40l5D'>

                          <tfoot id='40l5D'></tfoot>

                            <tbody id='40l5D'></tbody>

                            主站蜘蛛池模板: 九九九久久国产免费 | 国产欧美一区二区三区另类精品 | 国产91观看 | 黄色大片在线视频 | 国产日产精品一区二区三区四区 | 国产在线精品区 | 18性欧美 | 在线a视频网站 | 毛片一区二区三区 | 亚洲网站在线播放 | 国产精品福利在线观看 | 日本久久精品视频 | 99久久夜色精品国产亚洲96 | 一区观看| 久久伊人操 | 日日噜噜噜夜夜爽爽狠狠视频, | 日本中文字幕在线视频 | 九九热在线视频 | 日韩精品一区二区三区中文在线 | 北条麻妃国产九九九精品小说 | 中文字字幕一区二区三区四区五区 | 国产性网 | 男女羞羞的网站 | 亚洲精品视频一区二区三区 | jlzzjlzz国产精品久久 | 久久综合九九 | 国产精品日产欧美久久久久 | 神马久久春色视频 | 中文字幕一区在线 | 日韩电影免费在线观看中文字幕 | 欧美成年网站 | 国产成人精品999在线观看 | 色偷偷噜噜噜亚洲男人 | 国产一区 日韩 | 日韩欧美视频免费在线观看 | 久久鲁视频| 欧美一级免费 | 国产麻豆乱码精品一区二区三区 | 天天干人人 | 一区二区三区在线免费观看 | 精品久久精品 |