473,503 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

createDocumentFragment

(Working in FireFox)

I trying to build a minimal optimized HTML template engine in
JavaScript and I have some problems with what I trying to do.

I want in the most efficient way load a html file (valid XHTML) file
with XmlHttpRequest, parse it and insert into my html document.

var frag = document.createDocumentFragment();
frag.innerHTML = loadedSrc;

....fails.

Any suggestions?

Mar 22 '06 #1
1 2573

ni*********@gmail.com wrote:
I want in the most efficient way load a html file (valid XHTML) file
with XmlHttpRequest, parse it and insert into my html document.


You say you want to load a valid XHTML document and then you want to
insert the complete XHTML into another HTML document? I don't understand
that, how does one complete document fit into another document?

As for loading XHTML with XMLHttpRequest in Firefox, either make sure
you serve the XHTML with an XML MIME type or use overrideMimeType to get
Firefox to parse the response as XML. Then you can use DOM Level 2
importNode to import nodes from one document (responseXML) into the
other (document) and afterwards DOM Level 2 Core methods like
appendChild or insertBefore or replaceChild work to have nodes inserted.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 22 '06 #2

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

Similar topics

4
1210
by: Befuddled | last post by:
I am writing a function to have its argument, HTML-containing string, return a DOM 1 Document Fragment, and so it seems the use of regular expressions (REs) is a natural. My problem is that the...
10
7105
by: Anand | last post by:
Hi, I am using JavaScript to replace a node in HTML Tree. Currently I am using Mozilla and localhost to server files. 1. Eveytime I replace a node with a new node, the size of the new texts...
2
3140
by: Kael | last post by:
Hi, I’ve made a class to help me accomplish some things faster but I’m having problems inserting nodes. I’ve tried many different ways, but with no success. This is a very stripped down...
1
2308
by: apple | last post by:
Would someone help me? What, if anything, is wrong with the following code fragment? private XmlNode CreateStyles(XmlNode parent) { XmlDocumentFragment df =...
4
4162
by: David Grogan | last post by:
Hi, 2 questions.... 1. I'm parsing an XHTML document that contains both the default namespace (xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") - both of these being...
2
2268
by: ezmiller | last post by:
Hi, I have some code (which I will paste in below) that writes out some HTML dynamically using the W3C DOM...the last part of the code write out a simple table. MY problem is that the table is...
8
1519
by: murali.trichy | last post by:
Hi, I'm new to dotnet xml. I want to embed my part of xml to existing xml data using xmldocument. I think there is an option but i'm not getting exactly. eg: DocumentElement.InsertAfter is...
5
6138
by: john.teixeira | last post by:
Hey all, Sorry if this is a newbie question, but does javascript have a built-in function that will take a string, parse any HTML tags from the string and return back a DOM element representing...
5
13304
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.