Results 1 to 2 of 2

Thread: How do I work with HTML that is not valid XML

  1. #1
    Join Date
    Apr 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How do I work with HTML that is not valid XML

    Hi all,

    Sorry if this was already answered, I wasn't able to find good solution after few days of research.

    How do I find some elements in HTML loaded as QString, taking into account that HTML is not valid xml.
    I.e. some of its tags do not have corresponding closing tags:

    Qt Code:
    1. <style>
    2. pre.debug {
    3. white-space: pre-wrap;
    4. width: 90%;
    5. overflow: hidden;
    6. }
    7. </style>
    8. <link href="//fonts.googleapis.com/css?family=Open+Sans:300,400&lang=en" rel="stylesheet" type="text/css">
    9. <style>
    10. .banner {
    11. text-align: center;
    12. }
    13. </style>
    To copy to clipboard, switch view to plain text mode 


    In the example above QDomDocument::elementsByTagName() fails to return me <style> element that follows <link> element.
    I assume this is because <link> isn't closed properly.

    How do I address this with smallest effort?

    Thanks a lot in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How do I work with HTML that is not valid XML

    You could try loading it into a QWebPage and use its API to access the internal DOM structure.

    Cheers,
    _

Similar Threads

  1. How to combine multiple .html files together into one .html
    By stella1016 in forum Qt Programming
    Replies: 3
    Last Post: 12th October 2011, 06:34
  2. .lib is not a valid Qt plugin
    By rickrvo in forum Qt for Embedded and Mobile
    Replies: 11
    Last Post: 21st May 2011, 23:18
  3. No valid Qt version set?
    By RoryWalsh in forum Qt Tools
    Replies: 4
    Last Post: 21st October 2009, 08:02
  4. QGLWidget::isValid() not valid in Qt-4.3.2?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2008, 22:14
  5. valid a path name
    By klaus1111 in forum Newbie
    Replies: 3
    Last Post: 23rd July 2006, 15:07

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.