Results 1 to 8 of 8

Thread: Qt way of getting/parsing style attributes from html tags? local file batch

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Thumbs up Qt way of getting/parsing style attributes from html tags? local file batch

    I have this old and dirty code I wrote some years ago that basically parsed css styles from local html documents. That code is really really ugly, and I would like to Qtify it!

    I don't need rendering the webpage at all, just opening local files, reading them and closing them (in batch). How would you guys tackle this?

    I first thought using the webkit somehing like:
    Qt Code:
    1. QWebPage page;
    2. QWebFrame * frame = page.mainFrame();
    3. QUrl fileUrl("localFile.html");
    4. frame->setUrl(fileUrl);
    5. QWebElement document = frame->documentElement();
    6. QWebElementCollection elements = document.findAll("div");
    7. foreach (QWebElement element, elements){
    8. std::cout << element.attribute("style").toStdString() << std::endl;
    9. }
    To copy to clipboard, switch view to plain text mode 
    That didn't work... Why?

    Can I work with html files like legal xml? In that case, getting the attributes from the styles is going to be somewhat annoying, knowing all the styles are declared in the "head"...

    Any ideas, what Qclasses can be helpful here?
    Last edited by toglia3d; 10th June 2010 at 16:24.

Similar Threads

  1. QRegExp for extracting the string between two HTML tags...
    By tuthmosis in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2010, 06:55
  2. Matching HTML tags
    By pucara_faa in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2010, 13:19
  3. Html tags in QTreeView
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2009, 01:41
  4. QFontMetrics and HTML tags
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 14th August 2008, 12:13
  5. Replies: 1
    Last Post: 17th March 2006, 08:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.