xml to html conversion
-
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 -
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,
~ RudreshI 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();
-
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();
@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?
-
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();