Skip to content Skip to sidebar Skip to footer

Vb.net - Getting A String/value Of A Element Html?

I'm having a slight issue trying to get string from a element on a website. What I'm aiming for: Basically i'm trying to get a string/value from a website and make it go into a Tex

Solution 1:

HTML page is same as xml, so you can parse string to XDocument object and query that object to find information you need.

'Dim url As String = "http://www.ip-tracker.org/locator/ip-lookup.php?ip=" & TextBox1.TextDim url AsString = $"http://www.ip-tracker.org/locator/ip-lookup.php?ip={TextBox1.Text}"Dim data AsString = webClient.DownloadString(url)

Dim htmlPage As XDocument = XDocument.Parse(data)

Dim header As XElement = 
    htmlPage.Descendants("th").
    Where(Function(thElement) thElement.Value.Equals("IP Address:")).
    FirstOrDefault()

Above is the example of how you can find specific node from xml document. Use same approach to find value you need.

Post a Comment for "Vb.net - Getting A String/value Of A Element Html?"