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
QtWS25 Last Chance

xml to html conversion

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 346 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 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
    0
    • R Rudresh

      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 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();
      
      JonBJ C 2 Replies Last reply
      0
      • R Rudresh

        @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();
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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

          @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 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

          • Login

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