Javascript / XML

Shawn P. Garbett listman at garbett.org
Thu Jun 19 21:37:13 BST 2003


On Thursday 19 June 2003 02:26 pm, Shawn P. Garbett wrote:
> On Thursday 19 June 2003 2:14 pm, Alex Russell wrote:
> >On Thursday 19 June 2003 1:58 pm, Shawn P. Garbett wrote:
> >> What level of XML support is in Javascript?
> >
> >...
> >Konqueror has pretty good DOM support for (X)HTML documents, although
> >I can't speak to how well konq supports XML with arbitrary DTDs.
>
> Well my experience so far is that it doesn't, at all. The load method just
> throws and exception the moment I try to load an XML document.

I decided to see if I could get javascript to load a valid HTML or XHTML with 
the same code. It throws an exception and exits, so even this is causing me 
grief.

Is document.load a standard function? If not, how do I load a document in 
"standard" javascript?

<html><head><title>crash.html</title></head>
<body>
<script type="text/javascript">
function loadHTML(url)
{
  alert("loadHTML("+url+")");

  try 
  {
    // Use the standard DOM Level 2 technique, if it is supported
    if (document.implementation && document.implementation.createDocument)
    {
     // Create a new Document object
      var xmldoc = document.implementation.createDocument("", "", null);
      xmldoc.load(url);
      alert("Made the load");
    }
  }
  catch(ex)
  {
    alert ("CAUGHT EXCEPTION!");
  }
}

loadXML(location.href);

</script> </body> </html>






More information about the kfm-devel mailing list