Problems manipulating the khtml DOM

Ravikiran Rajagopal ravi at ee.eng.ohio-state.edu
Sun Oct 27 01:11:05 GMT 2002


Hello,
  DOM::HTMLElement::appendChild() seems to throw a NOT_FOUND_ERR exception 
when it should not. I tried to track the problem down to 
DOM::NodeImpl::appendChild() but I quickly got lost. Here's a simple test 
case which throws the NOT_FOUND_ERR exception:
-----------------------------------------------------
#include <kapplication.h>
#include <kdebug.h>
#include <khtml_part.h>
#include <dom/html_base.h>
#include <dom/html_document.h>
#include <dom/dom_exception.h>
#include <dom/dom_text.h>

int main( int argc, char **argv )
{
  KApplication rk( argc, argv, "Testing" );

  KHTMLPart p;
  p.begin();
  p.write("<HTML><TITLE>title</TITLE></HEAD><BODY>Body</BODY>");
  p.end();

  DOM::HTMLDocument doc = p.htmlDocument();
  if(doc.isNull())
    return 0;
  kdDebug() << "Doc is not null." << endl;

  DOM::HTMLBodyElement body = doc.body();
  if(body.isNull())
    return 0;
  if(!(body.hasChildNodes()))
    kdDebug() << "No children for body." << endl;
  DOM::Text child = (DOM::Text)(body.lastChild());
  if(child.isNull())
    return 0;
  kdDebug() << "Last child: "  << child.data().string() << endl;

  DOM::Text txt;
  txt.setData("Some text");

  try { body.appendChild(txt); }
  catch(DOM::DOMException ex)
  {
    kdDebug() << "Error number: " << ex.code << endl;
    return 0;
  }

  p.show();
  return rk.exec();
}
-----------------------------------------------------

Am I doing something wrong? I am using HEAD from about 3 days ago. In case it 
matters, I am using gcc-3.2. Could someone point me to the right direction in 
which to look?

Thanks,
Ravi

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<




More information about the kfm-devel mailing list