Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. xml to html conversion
Forum Updated to NodeBB v4.3 + New Features

xml to html conversion

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 357 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rudresh
    wrote on 19 Jun 2023, 06:54 last edited by
    #1

    Hi ,
    I wanted to convert xml to html. ( 6.5 ) using xslt file ( style sheet ) .
    Can any one please give some pointers ( have checked :
    Qt XML Patterns : deprecated , QTextDocumentWriter : could not find any functions which can set style sheet file. )

    thanks & warm regards,
    ~ Rudresh

    R 1 Reply Last reply 20 Jun 2023, 04:59
    0
    • R Rudresh
      19 Jun 2023, 06:54

      Hi ,
      I wanted to convert xml to html. ( 6.5 ) using xslt file ( style sheet ) .
      Can any one please give some pointers ( have checked :
      Qt XML Patterns : deprecated , QTextDocumentWriter : could not find any functions which can set style sheet file. )

      thanks & warm regards,
      ~ Rudresh

      R Offline
      R Offline
      Rudresh
      wrote on 20 Jun 2023, 04:59 last edited by
      #2

      @Rudresh

      I have tried following code , but its not as it should be.

      QFile myFile("D:/Report.xml");
      if (!myFile.open(QIODevice::ReadOnly | QIODevice::Text))
      return -1 ;
                     
      QString contents = myFile.readAll();
      
      QTextDocument qd (contents);
      
      myFile.close();
                
      QFile cssFile(      "Report.xslt");
      
      cssFile.open(QFile::ReadOnly);
      qd.setDefaultStyleSheet(cssFile.readAll());
      
      //qd.setHtml(cssFile.readAll());
      
      //QString html = qd.tr(cssFile.readAll());
      
      qd.setHtml(contents);
      
      
      QString html = qd.toHtml();
      
      qDebug() << html ;
      
      
      QFile outfile ("report.html");
      
      if ( !outfile.open(QIODevice::WriteOnly) )
          return -1 ;
      
      QTextStream out(&outfile);
      
      out << html ;
      
      outfile.close();
      
      J C 2 Replies Last reply 20 Jun 2023, 06:18
      0
      • R Rudresh
        20 Jun 2023, 04:59

        @Rudresh

        I have tried following code , but its not as it should be.

        QFile myFile("D:/Report.xml");
        if (!myFile.open(QIODevice::ReadOnly | QIODevice::Text))
        return -1 ;
                       
        QString contents = myFile.readAll();
        
        QTextDocument qd (contents);
        
        myFile.close();
                  
        QFile cssFile(      "Report.xslt");
        
        cssFile.open(QFile::ReadOnly);
        qd.setDefaultStyleSheet(cssFile.readAll());
        
        //qd.setHtml(cssFile.readAll());
        
        //QString html = qd.tr(cssFile.readAll());
        
        qd.setHtml(contents);
        
        
        QString html = qd.toHtml();
        
        qDebug() << html ;
        
        
        QFile outfile ("report.html");
        
        if ( !outfile.open(QIODevice::WriteOnly) )
            return -1 ;
        
        QTextStream out(&outfile);
        
        out << html ;
        
        outfile.close();
        
        J Offline
        J Offline
        JonB
        wrote on 20 Jun 2023, 06:18 last edited by
        #3

        @Rudresh said in xml to html conversion:

        but its not as it should be.

        We don't know what that means.

        I may be mistaken, but I thought @Christian-Ehrlicher replied to an identically-worded question yesterday saying that you would need a third-party library to convert XML to HTML as Qt does not offer this?

        1 Reply Last reply
        0
        • R Rudresh
          20 Jun 2023, 04:59

          @Rudresh

          I have tried following code , but its not as it should be.

          QFile myFile("D:/Report.xml");
          if (!myFile.open(QIODevice::ReadOnly | QIODevice::Text))
          return -1 ;
                         
          QString contents = myFile.readAll();
          
          QTextDocument qd (contents);
          
          myFile.close();
                    
          QFile cssFile(      "Report.xslt");
          
          cssFile.open(QFile::ReadOnly);
          qd.setDefaultStyleSheet(cssFile.readAll());
          
          //qd.setHtml(cssFile.readAll());
          
          //QString html = qd.tr(cssFile.readAll());
          
          qd.setHtml(contents);
          
          
          QString html = qd.toHtml();
          
          qDebug() << html ;
          
          
          QFile outfile ("report.html");
          
          if ( !outfile.open(QIODevice::WriteOnly) )
              return -1 ;
          
          QTextStream out(&outfile);
          
          out << html ;
          
          outfile.close();
          
          C Offline
          C Offline
          ChrisW67
          wrote on 20 Jun 2023, 06:45 last edited by
          #4

          @Rudresh said in xml to html conversion:

          QFile cssFile( "Report.xslt");

          An Extensible Stylesheet Language Transformation (XSLT) is not a HTML Cascading Style Sheet (CSS). This is "not as it should be."

          1 Reply Last reply
          1

          1/4

          19 Jun 2023, 06:54

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved