Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:56:03+00:00 2026-06-11T08:56:03+00:00

I am currently using Hpple to parse HTML, like so: TFHpple *htmlParser = [TFHpple

  • 0

I am currently using Hpple to parse HTML, like so:

TFHpple *htmlParser = [TFHpple hppleWithHTMLData:[currentString dataUsingEncoding:NSUTF8StringEncoding]];
NSString *paragraphsXpathQuery = @"//p//text()";
        NSArray *paragraphNodes = [htmlParser searchWithXPathQuery:paragraphsXpathQuery];
        if ([paragraphNodes count] > 0) {
            NSMutableArray *tempArray = [NSMutableArray array];
            for (TFHppleElement *element in paragraphNodes) {
                [tempArray addObject:[element content]];
            }
            article.paragraphs = tempArray;
        }

This way I get an array of paragraphs and I can use NSString *result = [myArray componentsJoinedByString:@"\n\n"]; to compile it into a single body of text with line breakes.

However, if the html contains tags, they are interpreted as individual entities and will get line breaked on their own right, so at the end of the day from a line like this:

<p>I went to the <a href="blablabla.html">shop</a> to get some milk!</a></p>
<p>It was awesome.</p>

I get this:

I went to the

shop

to get some milk!

It was awesome!

And of course I would like to get this (ignore other tags inside the p tag):

I went to the shop to get some milk!

It was awesome!

Can you help me out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:56:04+00:00Added an answer on June 11, 2026 at 8:56 am
    NSString *HTMLTags = @"<[^>]*>"; //regex to remove any html tag
    
    NSString *htmlString = @"<html>bla bla</html>";
    NSString *stringWithoutHTML = [hstmString stringByReplacingOccurrencesOfRegex:myregex withString:@""];
    

    don’t forget to include this in your code : #import “RegexKitLite.h” here is the link to download this API : http://regexkit.sourceforge.net/#Downloads

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using inline javascript to clear an input text's default value on focus.
Im currently using a plugin called Cycle for jQuery and would like to tweak
Im currently using a UITableView like any other, and I am researching into the
I am currently using matplotlib.pyplot to create graphs and would like to have the
Currently I am parsing my text using the PHP5 PEAR BBCode parser. Now I
currently using PHP5 with htmlMimeMail 5 ( http://www.phpguru.org/static/mime.mail.html ) to send HTML e-mail communications.
Im currently using a method that looks like the following code to add script
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
Currently using Google Analytics as a supplement to our paid tracking software, but neither
Currently using MySQL version 5.1.6 This is my first real world build and so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.