[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: associating a HTMLTableColElement to a table with khtml/dom?
From:       Emmanuel Touzery <emmanuel.touzery () wanadoo ! fr>
Date:       2001-05-06 18:24:12
[Download RAW message or body]

>Look at the DTD for html. The <col> element has to come first, before any 
>table rows. So if you have a table with rows and try to append a col element 
>this will give an exception. It should work if you try to insert it as first 
>child into the table ( table.insertBefore( table.firstChild(), col ) ).
>
>Cheers,
>Lars

Hi,

actually it doesn't work! i thought it did since i pasted directly your hint, 
but i think you had the order of the parameters wrong...

actually i did that at first, but i moved to appendChild (since it was 
documented not to produced exception 8). i think you meant
table.insertBefore( col, table.firstChild()  ) (order of parameters), and for 
me it doesn't work :o(

i attach a small test file + makefile that procuces exception 8 here. i'm 
sorry if my code is blatantly wrong for you, but i can't find the error :o(

thank you.

emmanuel


["minimal.cpp" (text/x-c++)]

#include <dom/dom_node.h>
#include <dom/dom_exception.h>
#include <dom/html_table.h>
#include <khtml_part.h>
#include <fstream>
#include <kcmdlineargs.h>
#include <kapp.h>



int main(int argc, char *argv[])
{
  KApplication kapplication(argc, argv, "ktest");
  KHTMLPart *p=new KHTMLPart();
  p->begin();
  p->write("<html><body><table \
border=3><tr><td>1.1</td><td>1.2</td></tr><tr><td>2.1</td><td>2.2</td></tr></table></body></html>");
  p->end();
  p->show();
  DOM::Node tableNode = p->document().getElementsByTagName("TABLE").item(0);
  cout << tableNode.nodeName().string().latin1() << endl;
  DOM::HTMLTableColElement col;
  col.setSpan(1);
  try {
    tableNode.insertBefore( col, tableNode.firstChild() ) ;
  }
  catch (DOM::DOMException e) {
    cout << "dom exception " << e.code << endl;
  }
//    return kapplication.exec();
}


["Makefile" (text/x-makefile)]

all:
	g++ minimal.cpp -I${KDEDIR}/include/ -I${QTDIR}/include -lqt -lkhtml -lkdecore \
-L${KDEDIR}/lib -lkdeui -L${QTDIR}/lib



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic