Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
help me to get "hello world"
<table cellpadding="0" cellspacing="0" id="id_tbl" class=" cke_show_border">
  <tbody>
     <tr>
       <td>
         <span class="title_editor">Heading</span>
       </td>
     </tr>
     <tr>
        <td class="content_tbl" id="id_td">
          <p align="center" style="text-align:center; margin:0in 0in 0.0001pt">
            <span style="font-size:14pt">
              <span style="line-height:150%">
                <span style="font-family:"Times New Roman",serif">
                   < b> hello world < /b>
                </span>
              </span>
             </span>
            </p>
           </td>
          </tr>
      </tbody>
</table>

Xpath: //*[@id="id_td"]/p/span/span/span/b/text()

What I have tried:

I have tried:
string curUrl = geckoWebBrowser1.Url.ToString();
                HtmlWeb web = new HtmlWeb();
                HtmlAgilityPack.HtmlDocument doc = web.Load(curUrl);
                var nodes = doc.DocumentNode.SelectNodes("//*[@id='id_td']/p/span/span/span/b/text()");
                richTextBox1.Text = nodes.ToString();

Thanks!!!!
Posted
Updated 5-Jun-19 21:04pm
v3

1 solution

1) Your HTML is invalid - < b> and < /b> should be <b> and </b> without spaces.
2) SelectNodes returns an array of nodes, you can access the text of the first node with: nodes[0].InnerText (but it's also worth checking that the array is not empty before trying to access its values).
 
Share this answer
 
Comments
Member 13923913 6-Jun-19 3:57am    
Thanks, i've tried, but it's not working
Thomas Daniels 6-Jun-19 4:05am    
How is it "not working"? Is there an error? A wrong result?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900