Results 1 to 4 of 4

Thread: convert htmlnode to int

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    184

    convert htmlnode to int

    Hello dear friends,

    i have the htmlAgilityPack and i can get the content of an element from an html website. My problem is i need to convert it to integer so i can do mathematic operations with it.
    Code:
     Dim treffer As HtmlNode = doc.DocumentNode.SelectSingleNode("//span[@class='hit-counter']")
    if i try to convert it to int it always says htmlnode can not be convertedto int.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: convert htmlnode to int

    Correct... what you have is a node... it's not something that can be converted into a number. presumably the number is part of the htmlnode somehow... you'll need to do some further extraction to get to it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: convert htmlnode to int

    You use the InnerText property to get the content.

    VB.NET Code:
    1. Convert.ToInt32(treffer.InnerText)
    Last edited by KGComputers; Jun 1st, 2016 at 11:22 AM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2014
    Posts
    184

    Re: convert htmlnode to int

    Thank you very much, works now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width