Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug QDomElement in QtXml?

I've got a QDomElement, and I would like to debug it, i.e. see it as plain text in debug console. In order to output it with qDebug(), it needs to be in QString format, however I don't see any conversion method from a QDomElement nor a QDomNode.

Any idea? Thanks!

like image 962
moala Avatar asked Dec 27 '22 15:12

moala


1 Answers

There is no built-in operator for streaming DOM elements to QDebug. You could write one easily enough, something like:

QDebug operator<<(QDebug dbg, const QDomNode& node)
{
  QString s;
  QTextStream str(&s, QIODevice::WriteOnly);
  node.save(str, 2);
  dbg << qPrintable(s);
  return dbg;
}
like image 166
Dan Milburn Avatar answered Dec 31 '22 14:12

Dan Milburn