Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to figure out XPath in HtmlAgilityPack
    text
    copied!<p>I have trying to get around making my first C# application(that can do more than just say "Hello world"),</p> <p>now the html file got lots of tags,(but got only two h4 tags that are given below.) but here is the part that i am interested in: </p> <pre><code>&lt;table width="100%" height="400" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" background="images/page_bg.gif" style="BORDER-COLLAPSE: collapse"&gt; &lt;tbody valign="top"&gt; &lt;tr&gt; &lt;td&gt; &lt;table width="80%" border="0" valign=top background="images/page_bg.gif"&gt; &lt;tr&gt; &lt;td&gt; &lt;div align="center"&gt; &lt;h4 align="center"&gt; &lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt; &lt;b&gt; &lt;font size="4" face="Arial, Helvetica, sans-serif"&gt; UNWANTED TEXT &lt;/font&gt;&lt;/b&gt;&lt;/font&gt;&lt;/h4&gt; &lt;p&gt;&lt;br /&gt; Name : {NAME HERE} &lt;br&gt;Number : {NUMBERS HERE}&lt;br&gt;Number2 : {NUMBERS2}&lt;br&gt;&lt;br&gt;&lt;h4&gt;UNWANTED TEXT&lt;/h4&gt;&lt;br&gt;detail NO. : &lt;span class=style7&gt;{NUmbers3}&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;a href=http://test.xom&gt;UNWANTED TEXT&lt;/a&gt;&lt;br&gt;&lt;br&gt; &lt;/p&gt; &lt;p class="content"&gt;&lt;em&gt;&lt;strong&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; </code></pre> <p>I wish to get NAME,Numbers1,Numbers2,Numbers3, So, i guess i got to do something like this =</p> <pre><code> //div[@align = "centre"]/h4/followingsibling::Text(); </code></pre> <p>but surely it is incomplete, any ideas on how should i do it, I got the Xpath from firebug : <code>/html/body/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr/td/div/h4</code></p> <p>i have also tried doing(for just getting the raw data first and then trimming it further)</p> <pre><code> HtmlNodeCollection node = doc.DocumentNode.SelectNodes("//table[@height='400']//div[@align='centre']"//p); foreach(HtmlNode node1 in node) textBox1.Text += node1.InnerText; </code></pre> <p>But the Node here is passed on as NULL Any help is greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload