5 Replies - 640 Views - Last Post: 21 August 2017 - 02:06 PM Rate Topic: -----

#1 UnknownProgrammer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-August 17

How do I get text from HTML tags?

Posted 20 August 2017 - 02:44 PM

Alright, so I was making a tool and I was trying to figure out how to get text from a HTML tag. Basically, there's one button and a richTextbox. You click the button and it outputs all the text from <p></p> in a website.
Is This A Good Question/Topic? 0
  • +

Replies To: How do I get text from HTML tags?

#2 JapanDave  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 365
  • Joined: 01-February 16

Re: How do I get text from HTML tags?

Posted 20 August 2017 - 03:02 PM

I would use RegEx, but there is a HTML agility pack that can also help with this.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13401
  • View blog
  • Posts: 53,498
  • Joined: 12-June 08

Re: How do I get text from HTML tags?

Posted 20 August 2017 - 03:17 PM

So you input a site and it scrapes the information? What site are you scraping?
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5831
  • View blog
  • Posts: 19,879
  • Joined: 05-May 12

Re: How do I get text from HTML tags?

Posted 20 August 2017 - 07:16 PM

With XHTML, then yes a RegEx may help, but you will still run into issues. With plain old HTML, you'll definitely run into issues because the <p> tag is not required to be closed. In both cases, you will have to deal with embedded tags like in this example:
<p>Power corrupts, but <strong>absolute</strong> power is kinda neat.</p>



Definitely go with the HTML Agility Pack. It will save you hours of digging through RFCs, and frustration with people who did not follow the RFCs.
Was This Post Helpful? 0
  • +
  • -

#5 Thomas1965  Icon User is offline

  • D.I.C Regular

Reputation: 61
  • View blog
  • Posts: 257
  • Joined: 09-September 16

Re: How do I get text from HTML tags?

Posted 21 August 2017 - 12:15 AM

Another option is csQuery. https://github.com/jamietre/CsQuery
Was This Post Helpful? 1
  • +
  • -

#6 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5831
  • View blog
  • Posts: 19,879
  • Joined: 05-May 12

Re: How do I get text from HTML tags?

Posted 21 August 2017 - 02:06 PM

Such a cool project! Too bad it's been abandoned...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1