Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to display data in correct format using HTML agility
    primarykey
    data
    text
    <p>Am having an HTML document and from that want to fetch necessary information so have used HTML agility concept. Using the following code am getting all the necessary data.</p> <pre><code> var web = new HtmlWeb(); var doc = web.Load("http://www.talentsearchpeople.com/en/jobs/?page=joblisting&amp;pubID=&amp;formID=&amp;start=0&amp;count=8&amp;module=&amp;functionLevel1=&amp;provinceNode=&amp;countryNode=&amp;keyword="); var nodes = doc.DocumentNode.SelectNodes("//a[@class='grijs'][@title]"); foreach (var node in nodes) { HtmlAttribute att = node.Attributes["title"]; title = att.Value; Response.Write("&lt;br/&gt;" + att.Value); } var Location = doc.DocumentNode.SelectNodes("//td[@width='80']"); foreach (var node in Location) { if (node.InnerHtml.Contains("Location:")) { locationname = HttpUtility.HtmlDecode(node.NextSibling.NextSibling.InnerText.Trim()); Response.Write("&lt;br/&gt;Location1=" + locationname); } } </code></pre> <p>Using the above code am getting following output:</p> <p>** Lead Buyer South</p> <p>Customer Service Order Management with native level of German</p> <p>EMEA Customer Experience &amp; Quality Internship</p> <p>Service Desk Team Leader with Excellent Level of German and French</p> <p>Sourcing &amp; Procurement Consultant with native level of French</p> <p>Jefe/a de ventas con alemán e inglés. Recien Titulados.</p> <p>Jefe/a de ventas con alemán e inglés. Recien Titulados.</p> <p>Jefe/a de ventas con alemán e inglés. Recien Titulados.</p> <p>Location1=Almeria</p> <p>Location1=Terrassa</p> <p>Location1=United Kingdom, Manchester</p> <p>Location1=Barcelona</p> <p>Location1=Barcelona</p> <p>Location1=A Coruña</p> <p>Location1=Cataluña</p> <p>Location1=Murcia **</p> <p>Above code works correctly for fetching of the data. Problem is i want to insert above data in database and also want to display the data in correct format means first title of the property followed by its location **Lead Buyer South Location1=Almeria</p> <p>Customer Service Order Management with native level of German Location1=Terrassa</p> <p>EMEA Customer Experience &amp; Quality Internship Location1=United Kingdom, Manchester</p> <p>Service Desk Team Leader with Excellent Level of German and French Location1=Barcelona</p> <p>Sourcing &amp; Procurement Consultant with native level of French Location1=Barcelona</p> <p>Jefe/a de ventas con alemán e inglés. Recien Titulados. Location1=A Coruña</p> <p>Jefe/a de ventas con alemán e inglés. Recien Titulados. Location1=Cataluña</p> <p>Jefe/a de ventas con alemán e inglés. Recien Titulados. Location1=Murcia**</p> <p><strong>Alternative Method by searching the table tag</strong></p> <pre><code> var web = new HtmlWeb(); var doc = web.Load("http://www.talentsearchpeople.com/en/jobs/?page=joblisting&amp;pubID=&amp;formID=&amp;start=0&amp;count=8&amp;module=&amp;functionLevel1=&amp;provinceNode=&amp;countryNode=&amp;keyword="); var mainNode = doc.DocumentNode.SelectNodes("//table[@class='border-jobs']/*"); foreach (var mainNodes in mainNode) { string pathdet = mainNodes.XPath; var nodes = mainNodes.SelectSingleNode("//a[@class='grijs'][@title]"); if (nodes != null) { HtmlAttribute att = nodes.Attributes["title"]; title = att.Value; Response.Write("&lt;br/&gt;" + att.Value); } var Description = doc.DocumentNode.SelectSingleNode("//td[@colspan='2']"); if (Description.InnerHtml.Contains("Description:")) { s = Description.InnerHtml; s = s.Replace("Description:", ""); Response.Write("&lt;br/&gt;Description=" + s); } var Location = doc.DocumentNode.SelectSingleNode("//td[@width='80']"); if (Location.InnerHtml.Contains("Location:")) { locationname = HttpUtility.HtmlDecode(Location.NextSibling.NextSibling.InnerText.Trim()); Response.Write("&lt;br/&gt;Location1=" + locationname); } } </code></pre> <p>If i use the above code then i get following output:</p> <p>Assistant Call Centre Manager with fluent level of Spanish and English</p> <p>Description= We are recruiting an Assistant Call Center Manager for a multinational company based in Lisboa, Portugal. This person will be responsible for the team management. Experience in team management, mainly in contact center, environment is required. </p> <p>Location1=Lisboa, Portugal</p> <p>I get the above output 8 times as <strong>//table[@class='border-jobs']/*</strong> tag occurs 8 times in the document</p> <p>how can i get correct output?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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