473,383 Members | 1,837 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,383 software developers and data experts.

XML Document from InnerHTML

SJ
Hi,

So I am trying to save off my source HTML to an xml document in order
to cache a large view within my ajax app.

For those of you familiar with this, the innerHTML does not preserve
the quotes around attributes so creating the xml document from
innerHTML is a pain (in IE).

The way I am doing it now is by calling
xmldoc.loadXML( addQuotesToAttributes(document.body.innerHTML)).

The problem is that the addQuotesToAttributes (which I wrote) can
take some time. Does anyone know an easier way to do this? Using Ajax
to request the xml info from the DB is not a good option for me.

Thanks,
-SJ

Apr 10 '07 #1
3 3325
SJ said the following on 4/10/2007 12:01 PM:
Hi,

So I am trying to save off my source HTML to an xml document in order
to cache a large view within my ajax app.

For those of you familiar with this, the innerHTML does not preserve
the quotes around attributes so creating the xml document from
innerHTML is a pain (in IE).
IE doesn't do it wrong though as attributes are not required to be
quoted unless they contain characters that require quoting (ex: space).
The way I am doing it now is by calling
xmldoc.loadXML( addQuotesToAttributes(document.body.innerHTML)).
Loop through the body and any and all attributes simply add a space to
the end of it and IE will quote it. When you get ready to save it or
reprocess it strip the space.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 10 '07 #2
SJ
On Apr 10, 4:17 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
SJ said the following on 4/10/2007 12:01 PM:
Hi,
So I am trying to save off my source HTML to an xml document in order
to cache a large view within my ajax app.
For those of you familiar with this, the innerHTML does not preserve
the quotes around attributes so creating the xml document from
innerHTML is a pain (in IE).

IE doesn't do it wrong though as attributes are not required to be
quoted unless they contain characters that require quoting (ex: space).
The way I am doing it now is by calling
xmldoc.loadXML( addQuotesToAttributes(document.body.innerHTML)).

Loop through the body and any and all attributes simply add a space to
the end of it and IE will quote it. When you get ready to save it or
reprocess it strip the space.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Thanks for the reply I will give this a shot.

-SJ

Apr 11 '07 #3
SJ
On Apr 10, 7:54 pm, "SJ" <sjour...@gmail.comwrote:
On Apr 10, 4:17 pm, Randy Webb <HikksNotAtH...@aol.comwrote:


SJ said the following on 4/10/2007 12:01 PM:
Hi,
So I am trying to save off my source HTML to an xml document in order
to cache a large view within my ajax app.
For those of you familiar with this, the innerHTML does not preserve
the quotes around attributes so creating the xml document from
innerHTML is a pain (in IE).
IE doesn't do it wrong though as attributes are not required to be
quoted unless they contain characters that require quoting (ex: space).
The way I am doing it now is by calling
xmldoc.loadXML( addQuotesToAttributes(document.body.innerHTML)).
Loop through the body and any and all attributes simply add a space to
the end of it and IE will quote it. When you get ready to save it or
reprocess it strip the space.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Thanks for the reply I will give this a shot.

-SJ- Hide quoted text -

- Show quoted text -
Ok, how do i get all the attributes in a body (and of course the child
elements as well) :)

Apr 11 '07 #4

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

Similar topics

14
by: christopher.secord | last post by:
Can someone please tell me why this works: document.body.innerHTML = "<table><tr><th>one</th></tr><tr><td>two</td></tr></table>"; But this does not work: document.body.innerHTML =...
3
by: Alexander Mikhailian | last post by:
I have an http = new XMLHttpRequest(); that provides me with an http.responseXML. Somewhere deep in the http.responseXML there is a fragment called e.g. mydom that I want to copy with all its...
6
by: adamrfrench | last post by:
Let it be mentioned that Javascript is not my forte, so the solution to this could very well be a simple one. I am working on an AJAX function where I can pass a URL and the target ID in, and...
2
by: robert.waters | last post by:
Hello, I am dynamically editing the contents of a page and using document.write() to reload the new, edited content. However, on the new page, any calls to functions located in external .js...
7
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one...
8
by: Henrik Stidsen | last post by:
I am trying to access a table in an iframe via javascript. It sounds easy - but it won´t work... The iframe is added to the document via someContainerElement.innerHTML = "<iframe...>", it has...
8
by: geoffdude | last post by:
Hi everyone, newbie here. I'm really close to finishing my zip code search filter thingy to return a specific message (ultimately a unique phone number for sales contact) after a form query (of...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
2
by: Big Guy 60 | last post by:
I can get this code to work in IE but not in firefox. I have a site with 20 <div> item throughtout the site. All of the <div> tags have unique ids. I am using an ajax call to hit a "heartbeat"...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.