Quote Originally Posted by wysota View Post
Because it is read only... That's why it's called a browser and not an editor.
Could be. Others have read the docs
Me to and i found only one to display html page + link css image and open link on firefox .

How you projekt a Wysiwyg xhtml editor without QTextBrowser ?
To make a preview inside you need this QTextBrowser.
QTextEdit dont dispay href link and open it. Boring event maybe? and make clickable.
Otherwise you must open a new window to display and test links...

Now i found a way to emulate XPath ....

Now the problem is to contruct a new QDomNodeList and append note to return on public code...

QDomNodeList not having append(node) !

Qt Code:
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <iostream>
  5. #include <QtCore>
  6. #include <QDomDocument>
  7.  
  8. class List_Tag
  9. {
  10. public:
  11. List_Tag( QDomDocument doc , const QString FindTagName , const QString AttributeName )
  12. {
  13. t = FindTagName;
  14. a = AttributeName;
  15.  
  16. std::cout << "Start Job search tag ->" << qPrintable(FindTagName) << std::endl;
  17. QDomNode n = doc.firstChild();
  18. if (n.hasChildNodes()) {
  19. Grep_Tag(n);
  20. }
  21. }
  22. protected:
  23. QString value;
  24. QString tagname;
  25. QDomNode node;
  26. private:
  27. void Grep_Tag( QDomNode n )
  28. {
  29. QDomNodeList list = n.childNodes();
  30. for (int i = 0; i < list.length(); ++i) {
  31. node = list.item(i);
  32. tagname = node.nodeName();
  33. std::cout << "Found tag loop->" << qPrintable(tagname) << std::endl;
  34. if (tagname == t && node.hasAttributes()) {
  35. value = node.toElement().attributeNode(a).value();
  36. if (!value.isEmpty()) {
  37. std::cout << "Result->" << qPrintable(tagname) << " attribute->" << qPrintable(value) << std::endl;
  38. }
  39. } else if (tagname == t && a.isEmpty()) {
  40. std::cout << "Result->" << qPrintable(tagname) << " and Empty attribute." << std::endl;
  41. }
  42. if (node.hasChildNodes()) {
  43. Grep_Tag(list.item(i));
  44. }
  45. }
  46. }
  47.  
  48. };
  49.  
  50. int main(int argc, char *argv[]) {
  51. QCoreApplication a( argc, argv );
  52.  
  53. const char *xml = "<test><tag>content 1</tag><tag>content 2</tag> "
  54. "<othertag>wrongcontent<p>text line <a href=\"/somelink\">link1</a></p></othertag>"
  55. "<tag>content 3 <div><p>text other <a href=\"/otherlink\">link2</a></p></div></tag></test>";
  56. bool ok = doc.setContent(QString(xml));
  57. if (ok) {
  58. List_Tag links(doc,"a","href");
  59. List_Tag paras(doc,"p","");
  60. }
  61. std::cout << "Main end..................." << std::endl;
  62. return a.exec();
  63. }
  64.  
  65. ////////#include "main.moc"
To copy to clipboard, switch view to plain text mode