Bug 5728 - createDocument should create a document element
Summary: createDocument should create a document element
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-13 11:21 PST by Anders Carlsson
Modified: 2019-02-06 09:03 PST (History)
2 users (show)

See Also:


Attachments
Add document element (12.25 KB, patch)
2005-11-13 11:36 PST, Anders Carlsson
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Carlsson 2005-11-13 11:21:51 PST
Currently, DOMImplementation::createDocument does not create a root document element.
Comment 1 Anders Carlsson 2005-11-13 11:36:40 PST
Created attachment 4681 [details]
Add document element
Comment 2 Eric Seidel (no email) 2005-11-13 11:42:29 PST
Comment on attachment 4681 [details]
Add document element

Looks good.  r=me.
Comment 3 Frederick C. Lee 2008-01-10 16:16:51 PST
Safari 3.0.4: The following code FAILS with the following:

TypeError: Value undefined (result of expression xmlDoc.load) is not object.
http://www.w3schools.com/xpath/tryit_view.asp?filename=try_xpath_select_cdnodes

Note: Safari passes the W3C conditional as stated, but *failed* in creating a DOM doc.

The code is:
<html>
<body>
<script type="text/javascript">
function loadXMLDoc(fname)
{
var xmlDoc;
// code for IE
if (window.ActiveXObject)
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
  {
  xmlDoc=document.implementation.createDocument("","",null);
  }
else
  {
  alert('Your browser cannot handle this script');
  }
xmlDoc.async=false;
xmlDoc.load(fname);
return(xmlDoc);
}

xml=loadXMLDoc("books.xml");
path="/bookstore/book/title"
// code for IE
if (window.ActiveXObject)
{
var nodes=xml.selectNodes(path);

for (i=0;i<nodes.length;i++)
  {
  document.write(nodes[i].childNodes[0].nodeValue);
  document.write("<br />");
  }
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
var nodes=document.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
var result=nodes.iterateNext();

while (result)
  {
  document.write(result.childNodes[0].nodeValue);
  document.write("<br />");
  result=nodes.iterateNext();
  }
}
</script>

</body>
</html>

---------

You can see for yourself via the following link:
http://www.w3schools.com/xpath/tryit.asp?filename=try_xpath_select_cdnodes

This works with Mozilla & IE; but *NOT* Safari 3.0.4 (Mac/Win).



Comment 4 Alexey Proskuryakov 2008-01-11 02:38:43 PST
Sure, we don't currently support the non-standard Document.load extension. This is a mistake for w3schools.com to recommend it.

And most certainly, this has nothing to do with the original bug.
Comment 5 Lucas Forschler 2019-02-06 09:03:44 PST
Mass moving XML DOM bugs to the "DOM" Component.