久久久久久久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>

                            主站蜘蛛池模板: 亚洲视频一区在线 | 欧美精品久久久 | 精品在线播放 | 先锋资源站 | 成年人的视频免费观看 | 亚洲成人一区二区 | 欧美不卡 | 久久久新视频 | 亚洲人精品午夜 | 午夜精品一区二区三区在线视频 | 亚洲激情在线观看 | 国产激情偷乱视频一区二区三区 | 日韩欧美网| 波多野结衣中文视频 | 国产亚洲一区二区三区在线观看 | 男女在线免费观看 | 亚洲成人二区 | 五月激情婷婷在线 | 国产精品久久久久久亚洲调教 | 亚洲视频在线一区 | av在线一区二区三区 | 亚洲精品免费观看 | 国产美女视频黄a视频免费 国产精品福利视频 | 亚洲区一区二区 | 另类视频在线 | 精品国产鲁一鲁一区二区张丽 | 九九福利 | 日本在线免费看最新的电影 | av中文字幕在线观看 | 日韩精品一区二区三区在线观看 | 女人牲交视频一级毛片 | 99久久婷婷国产综合精品电影 | 国产一卡二卡三卡 | 国产精品视频区 | 日韩精品专区在线影院重磅 | 欧美 日韩 视频 | 国产在线一区二 | 亚洲欧美在线观看 | 免费观看日韩精品 | 日韩久久久久久 | 一区二区视频 |