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 6836787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:23:53+00:00 2026-05-26T23:23:53+00:00

I have a dirty HTML code that is loaded from a foreign server (so

  • 0

I have a dirty HTML code that is loaded from a foreign server (so I can’t make a json file or clean the html code). My HTML’s structure is like:

<!-- SOME DIRTY HTML, CSS, JS, AND OTHER STUFF -->

<div class="pic"> ... </div>

<div class="pic" id="pic311809">

<input type="hidden" class="pic_id" name="pic_id" value="311809" />

<!-- tylko komixxy.pl -->
<div style="font-family: verdana, arial, helvetica, sans-serif; font-weight: bold; font-size: 9px;">
                                        <a href="pic/show_series/1">FFFUUU (rageman)</a>
        </div>

<h1 class="picture">Kochana babcia</h1>

<div class="infobar">
    Wrzucone 15 października 2010 o 16:03       przez <a href="/user/Astraly">Astraly</a>
    |
    <a href="http://komixxy.pl/311809/Kochana-babcia#comments">Skomentuj (23)</a>
    <!-- głosowanie przeniesione pod spód obrazka -->
</div><!-- .infobar -->


<div class="pic_image">
                <a href="http://komixxy.pl/311809/Kochana-babcia"><img src="http://staticrps.komixxy.pl/uimages/201010/1287151388_by_Astraly_500.jpg" class="pic" alt="Kochana babcia - Wnusiu, a ty jeszcze nie w szkole? Dziś mamy na 10 babciu Co ty tam majaczysz? Jesteś na wagarach!? już ja to powiem twojej mamie! Ale babciu.... Przynosisz nam wstyd! Myślisz, że nie wiem o tej ostatniej niedzieli, w której nie byłeś u komunii? ZAMKNIJ SIĘ KU**A!!!! .... Nie musisz tak krzyczeć! Powiem twojej mamie z jakim tonem odnosisz się do mnie! " /></a>          </div><!-- .pic_image -->

                <div class="source">Źródło: Kto mieszka z babcią, ten wie jak to jest ;)</div>

<!-- głosowanie i ocena -->

<div class="source">

    <div class="infobar center">

        Głosuj:

        <a href="/pic/vote/311809/up"
             onclick="votowanie(this); return false;"
             class="vote voteup iconlink"
        >
            mocne ↑         </a>

        &middot;

        <a href="/pic/vote/311809/down"
             onclick="votowanie(this); return false;"
             class="vote votedown iconlink"
        >
            słabe ↓         </a>


        <!-- DODATKOWY PRZYCISK RAPORTOWANIA DUPLIKATÓW (“BYŁO”) -->

        |

        <span class="points">
                                87% mocnych
                        </span>

        <span class="count">
                                z 1291 głosów
                        </span>

        <span class="vote_result"></span>

                    | <a href="/user/add_favorite/311809" class="favorite">Do ulubionych</a>


    </div><!-- .infobar -->

    <!-- PRZYCISK LAJKONIKA -->
    <div style="text-align: center;">
        <fb:like href="http://komixxy.pl/311809/Kochana-babcia"
                         layout="button_count"
                         show_faces="true"
                         width="130"
                         font="arial"
                         style="width: 130px;">
        </fb:like>
    </div>

    <!-- tylko komixxy.pl -->
    <a href="http://komixxy.pl/pic/show_group/311809" class="picbutton">Pokaż podobne komixxy</a>       <a href="http://komixxy.pl/przerob/311809" class="picbutton">Zrób własną wersję</a>
    <div style="clear: both;"></div>

</div><!-- .source -->



</div><!-- .pic -->

<div class="pic"> ... </div>

<div class="pic"> ... </div>

<div class="pic"> ... </div>

I want to select all <div class="pic" id="*"> by using xPath //div[@class='pic'][@id].

Here are two libraries that I used:

- Hpple
- TouchXML

As for Hpple -> it’s great but I can’t select innerHTML of an emelent. As for TouchXML, I use it for parsing XML and it’s great. But it doesn’t manage to parse dirty HTML – I get dozens of errors.

Is there a way to parse this HTML in iOS5 using TouchXML? It can be a different library, but I prefer that one.

I heard something about CTidy.h and I did as instructed but nothing’s changed…

  • 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-05-26T23:23:54+00:00Added an answer on May 26, 2026 at 11:23 pm

    libxml has a module designed exactly for this problem 🙂

    http://xmlsoft.org/html/libxml-HTMLparser.html

    It works exactly the same as libxml normally works i.e. to parse an NSData object containing dirty html:

    #include <libxml/htmlparser.h>
    
    htmlDocPtr doc; /* the resulting document tree */
    doc = htmlReadMemory([data bytes], [data length], "noname.xml", NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOWARNING | HTML_PARSE_NOERROR);
    if (NULL == doc)
        return nil;
    
    ... parse DOM here ...
    
    xmlFreeDoc(doc);
    

    compared to the libxml example from their website :

    xmlDocPtr doc; /* the resulting document tree */
    doc = xmlReadMemory(content, length, "noname.xml", NULL, 0);
    if (NULL == doc)
        return nil;
    
    ... parse DOM here ...
    
    xmlFreeDoc(doc);
    

    PS Don’t forget to include libxml2.dylib into your project as a framework in the ‘link binary with libraries’ project build phase

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

Sidebar

Related Questions

I have to retrieve this url from a dirty html page: ......... http://www.imdb.com/title/tt0092699/ ......
This is the scenario: we have a x.html page that could be loaded as
I have this dirty html that is currently used in my company, the issue
I have a JLabel that needs to display some html-formatted text. However, I want
I created a quick and dirty HTML file to demonstrate an issue I am
I have a HTML form that contains text fields, checkboxes, radiobuttons and a submit
I have some html that creates a dropdown list. The list has text values
I am converting XML children into the element parameters and have a dirty regex
Is there anyone who have encountered Processing Dirty Regions error in MyEclipse? Actually everytime
I'm trying to have a kind of dirty underline effect using a string of

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.