On QTextBrowser is not possibel to make a standard <a href=\"#\" target=\"xx\"> link...
target will remove after reload text ...!

So i search a iterate to handle this, my popup dialog link write a link so:
http://www.qtcentre.org/#target=_blank
After i rewrite this on php xml...

Now i found DomElementContainer from http://blog.wysota.eu.org/

i test so... und it can not find link... founf 0 . why wo i mistake?

Qt Code:
  1. const char *xml = "<test><tag>content 1</tag><tag>co<a href=\"#test\" target=\"xx\">ntent</a> 2</tag> "
  2. "<othertag>wrongcontent</othertag>"
  3. "<tag>content 3</tag></test>";
  4.  
  5. int main(){
  6. doc.setContent(QString(xml));
  7. DomElementContainer c(doc, "a");
  8. int link = 0;
  9. foreach(QDomElement e, c) {
  10. link++;
  11. }
  12.  
  13. qDebug() << "### total link found -> " << link;
  14.  
  15. return 0;
  16. }
To copy to clipboard, switch view to plain text mode 

on php i rewrite so....



Qt Code:
  1. function Rewrite_QT_Tag($xhtml) {
  2. /* rewrite not support target on QTextedit tag <a> */
  3. /* samble : <a href="http://www.qtcentre.org/#target=_blank">
  4.   <span style=" text-decoration: underline; color:#0000ff;">QtCentre</span>
  5.   </a>*/
  6. $dom = new XML();
  7. $dom->loadXML($xhtml);
  8. $xp = new DomXPath($dom);
  9. $xp ->registerNamespace('default','http://www.w3.org/1999/xhtml');
  10. $result = $xp->query("//default:a");
  11. foreach ($result as $node) {
  12. $attuale = $node->getAttribute("href");
  13. /* get text from qt span and insert text node.... */
  14. $testodentro ="";
  15. while($node->hasChildNodes()) {
  16. /* get span text inside <a><span>text link</span></a>*/
  17. $testodentro .=$node->childNodes->item(0)->nodeValue;
  18. $node->removeChild($node->childNodes->item(0));
  19. }
  20. $testodentro = eregi_replace("\n"," ",$testodentro);
  21. $testo = $dom->createTextNode($testodentro);
  22. $node->appendChild($testo);
  23.  
  24. /* rewrite target */
  25. if (eregi("#target=",$attuale)) {
  26. $params = explode("#target=", $attuale);
  27. $urigo = $params[0];
  28. $node->setAttribute("href",$urigo);
  29. /**/
  30. if (eregi("^(http|https)+(:\/\/)+[a-z0-9_-]+\.+[a-z0-9_-]", $urigo )) {
  31. $node->setAttribute("target","_blank");
  32. $node->setAttribute("class","Link_External");
  33. } else if (eregi('mailto:',$urigo)) {
  34. $node->setAttribute("class","Link_Mail");
  35. } else {
  36. $node->setAttribute("target",$params[1]);
  37. $node->setAttribute("class","Link_Internal");
  38. }
  39. /**/
  40. } else if (eregi("^(http|https)+(:\/\/)+[a-z0-9_-]+\.+[a-z0-9_-]", $attuale )) {
  41.  
  42. $node->setAttribute("target","_blank");
  43. $node->setAttribute("class","Link_External");
  44. } else {
  45. continue;
  46. }
  47. }
  48. /* end link rewrite */
  49. $xhtml = $dom->saveXML();
  50. return $xhtml;
  51. }
To copy to clipboard, switch view to plain text mode