Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have this html code, links between tags and i want to get those links to listbox.


heres my html code

HTML
<a name="b"></a>
	<div class="block">
		<h2>B</h2>
		<div class="box">
			<ul class="con1">
				<li>
					<a href="www.mylink1.com">asd1</a>
				</li>
				<li>
					<a href="www.mylink2.com">asd2</a>
				</li>
				<li>
					<a href="www.mylink3.com">asd3</a>
				</li>
				<li>
					<a href="www.mylink4.com">asd4</a>
				</li>
				<li>
					<a href="www.mylink5.com">Back to You</a>
Posted
Comments
Abhishek Pant 7-Mar-14 9:38am    
Html Agility Pack[^]

have a look at this..
Sergey Alexandrovich Kryukov 19-Mar-14 18:52pm    
What would it mean, "between tag"? At this moment, I have trouble reading between lines. :-)
—SA

1 solution

It looks like your HTML sample is valid XML, so you can parse it using one of the approaches offered by .NET FCL. This is my short overview of them:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


—SA
 
Share this answer
 

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