c++ - QDomNode 到 html

标签 c++ qt dom stream

我有 QDomNode 对象,我需要获取其中数据的 html 表示形式。我找到了一个方法 QDomNode::save( QTextStream & str, int indent ) :

Writes the XML representation of the node and all its children to the stream str. This function uses indent as the amount of space to indent the node.

我试过这样使用它:

QDomNode table = ...;

QString *htmlTable;
QTextStream stream(htmlTable);

table.save(stream, 2);
qDebug() << htmlTable;

QDebug 返回一个指针。在其他情况下,程序会失败。我想我用错了 QTextStream

最佳答案

您还没有为您的 QString 保留内存。

QString htmlTable;
QTextStream stream(&htmlTable);
table.save(stream, 2);

应该可以,但我还没有测试过。

关于c++ - QDomNode 到 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6817242/

相关文章:

javascript - Javascript 弹出框(警报、确认和提示)是 'document' 的一部分还是 'Browser'(客户端)的一部分

javascript - 在添加到 DOM 之前获取元素的高度

c++ - 如何为 std::vector 分配内存,然后为某些元素调用构造函数?

c++ - 如何在项目编辑期间清除 QTreeView 中的背景?

c++ - QTConcurrent 不编译

qt - QT Creator不想启动

c++ - 如何判断Qt是否调试

javascript - 遍历未知 DOM 的递归函数

c++ - 快速容器以实现一致的性能

c++ - BGL : Unable to access bundled vertex properties