locked
How can I can get values enclosed by <li> RRS feed

  • Question

  • This is the html hierarchy

    <div class="panel-body sozluk">
        			        			<ol>
        			        			<li>kitap <code>isim</code> </li></span>    			        	</ol>
        			        			</div>

    I am required to get values  indide  <li> tags.I dont need <code> values I have tried something like this

    HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); document.LoadHtml("info.html"); var v= document.DocumentNode.SelectNodes("//div [@class='panel-body sozluk']//ol").

    Cast<XElement>().Descendants("li").Select(x => x.Value).ToList();



    • Edited by alak41 Friday, April 3, 2015 11:42 AM
    • Changed type KareninstructorMVP Friday, April 3, 2015 1:52 PM This is a question
    • Moved by Caillen Thursday, April 9, 2015 8:05 AM
    Friday, April 3, 2015 11:41 AM

Answers

  • It seems to me that you should be posting to a fourm that deals with HTML, liek the ASP.NET foru,. Also you may also want to use Javascript for this, and again that would be at the ASP.NET forum.

    http://forums.asp.net/

    • Proposed as answer by Caillen Thursday, April 9, 2015 8:05 AM
    • Marked as answer by Just Karl Wednesday, April 15, 2015 8:27 PM
    Friday, April 3, 2015 2:38 PM

All replies

  • The element contains properties/attributes.  A property/attribute is like 'class' in the example you provided.  the info you are looking for could be in the 'innertext' property.  Try making this change

    From : x => x.Value

    To : x => x.InnerText


    jdweng

    Friday, April 3, 2015 12:00 PM
  • It seems to me that you should be posting to a fourm that deals with HTML, liek the ASP.NET foru,. Also you may also want to use Javascript for this, and again that would be at the ASP.NET forum.

    http://forums.asp.net/

    • Proposed as answer by Caillen Thursday, April 9, 2015 8:05 AM
    • Marked as answer by Just Karl Wednesday, April 15, 2015 8:27 PM
    Friday, April 3, 2015 2:38 PM
  • <ul id='myid'>
     
    <li id='1'>First</li>
     
    <li id='2'>Second</li>
     
    <li id='3'>Third</li>
     
    <li id='4'>Fourth</li>
     
    <li id='5'>Fifth</li>
    </ul>
    Friday, April 3, 2015 2:41 PM