Click here to Skip to main content
16,020,459 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anybody tell me how to extract data written between any tag from html pages in vb.net or c#???

for eg: consider an html document like

<html>
<head>
<title>dgdg</title>
</head>
<body>
<div id="body">
<p>hello this is what i want</p>
</div>
</body>
</html>

i want the text between <p> tag??? how to extract it??? will i have to go through each tag to reach that particular tag??

any solution - thanks
Posted

Your VB.NET Code will be something like this.

Dim first, last As String
           
            first = "<p>"
            last = "</p>"
            Dim RE As New Regex(first + _
              "(?<MYDATA>.*?(?=" + last + "))", _
              RegexOptions.IgnoreCase Or RegexOptions.Singleline)
            

            Dim m As Match = RE.Match(yourData)
            ' got the result

            Dim output As String
            output = m.Groups("MYDATA").Value
 
Share this answer
 
Use a Regular Expression to find the P tags and extract the text
 
Share this answer
 
Comments
amit_upadhyay 22-Jun-10 10:39am    
suppose there are many

tags and i want the one between div id="body then????

could u post a code snippet???

[no name] 22-Jun-10 11:00am    
"suppose there are many tags"
Suppose you actually understood software engineering and how to solve problems?

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