473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem adding HTML content loaded using document.load()

Hi,

I'm building a tree control that lazily loads branches of the tree
using the document.load() method.

The external XML document that is loaded is generated by a servlet as
XHTML. What I would like to do is to add the new tree branch to the
correct place in the document in the browser window using the innerHTML
property of the parent node.

The relevant code snippet that I've written to do this is:

var target = document.getElementById(parentId);
target.innerHTML = xmlDoc.documentElement.xml;

This doesn't work, furthermore looking at the W3C DOM API it would seem
that the document.xml property is a Microsort proprietary extension
which makes it unsuitable for my application.

Any pointers on where I'm going wrong are much appreciated.

Cheers
Adam

Jul 23 '05 #1
3 2109
ad**@prema.co.nz wrote:
<snip>
var target = document.getElementById(parentId);
target.innerHTML = xmlDoc.documentElement.xml;

This doesn't work, furthermore looking at the W3C DOM API it would seem
that the document.xml property is a Microsort proprietary extension
which makes it unsuitable for my application.


Why not

target.appendChild(xmlDoc.documentElement.cloneNod e(true));

?
Jul 23 '05 #2


Paul R wrote:
ad**@prema.co.nz wrote:
<snip>
var target = document.getElementById(parentId);
target.innerHTML = xmlDoc.documentElement.xml;

This doesn't work, furthermore looking at the W3C DOM API it would seem
that the document.xml property is a Microsort proprietary extension
which makes it unsuitable for my application.

Why not

target.appendChild(xmlDoc.documentElement.cloneNod e(true));


That is certainly the right idea in browsers like Mozilla (and its
derives Netscape 6/7, Firefox) and Opera 7 which have its own DOM
implementation dealing interoperable with both XML and HTML but then you
should do it properly and use

target.appendChild(target.ownerDocument.importNode (xmlDoc.documentElement,
true));

but I think the original poster is dealing with IE/Win which uses MSXML
for XML parsing and XML DOM stuff and unfortuntately there you cannot
simply move nodes from an MSXML XML DOM document to an IE HTML DOM
document, you are left with writing your own importNode method which
tediously creates all nodes/attributes as needed or you can use
innerHTML to have IE parse markup sent. I think Sarissa
(<http://sarissa.sourceforge.net/doc/>), a library trying to provide a
cross browser API for XML and XSLT stuff, implements importNode for IE
and in its implementation
(<http://sarissa.sourceforge.net/doc/overview-summary-sarissa.js.html>)
mentions that innerHTML has proven to be much faster for than using DOM
createXXX methods.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
Hi Paul, Martin

Thanks for clarifying how this works. I'm writing a cross-browser
script so I'm going to go with Sarissa, it seems to do a nice job of
hiding the browser-specific APIs.

Regards,
Adam

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
The problem I am having involves the sequence of events between frames in an html page. The Pages: Page A has an imbedded IFrame which displays Page B. Page A has a radio button which on...
7
by: Merlin | last post by:
Hi there, I have a problem with opening new windows with JS. If the webpage did not complete loading due to any reason a click on a link which is supposed to open a small new other window loads...
7
by: majid | last post by:
I want write a program with c# to pars a html file how ccan i do this with system.mshtml? or there is other way to do it p;ease help me?
1
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of...
3
by: Andy Baxter | last post by:
I have an image scrolling in a viewport for a panoramic image viewer. The viewport can be resized to several set resolutions so people can adjust the size according to their bandwidth. There are...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
1
by: wenijah | last post by:
Hi everyone! First thank you for reading this post and yes, you probably already see that kind of topic title somewhere but the problem I've got today might be different than the 100 topics I've...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.