473,407 Members | 2,320 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,407 software developers and data experts.

Node Replacement without HTML tags & empty responseXML


The situation is; I receive a response back from the server which i
only a part of html code. e.g. a table like <table
<tr><td>high</td></tr>........ </table>. In other words, I receive
file as a response which has a part of html file.

My aim is to replace an existing document node with the new response.

If I run the following lines (JavaScript):

var parsedText = document.createTextNode(req.responseText);
body.replaceChild(parsedText, toReplace)

It replaces the node 'toReplace' with html codes with the tags include
which is not what I want. The html tags are not wanted but shoul
display in correct format as specified by html (a tabular form if htm
tag is <table>)

If I try:

alert(responseXML); (its blank.... nth gets displayed in the aler
message)
var parsedText = document.createTextNode(req.responseXML);
body.replaceChild(parsedText, toReplace); (it replaces toReplace b
"[object]" in IE6)
Any kind of help will be appreciated.

Anan

--
Anan
-----------------------------------------------------------------------
Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
View this thread: http://www.highdots.com/forums/showthread.php?t=123946

Jul 23 '05 #1
4 1925

a similar issue was on this same form

http://www.highdots.com/forums/showt...51#post3327451
but it ended up without any specific solution..... and not ver
relevant to me either
Anan

--
Anan
-----------------------------------------------------------------------
Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
View this thread: http://www.highdots.com/forums/showthread.php?t=123946

Jul 23 '05 #2


Anand wrote:
The situation is; I receive a response back from the server which is
only a part of html code. e.g. a table like <table>
<tr><td>high</td></tr>........ </table>. In other words, I receive a
file as a response which has a part of html file.

My aim is to replace an existing document node with the new response.

If I run the following lines (JavaScript):

var parsedText = document.createTextNode(req.responseText);
body.replaceChild(parsedText, toReplace)


How about
toReplace.innerHTML = req.responseText;
? That should do what you want. Note that there might be smarter ways of
doing things if you use Mozilla as there you could directly load XHTML
and then use DOM importNode but as you have not shown us the context the
innerHTML assigment is probably your best bet at cross browser replacement.
--

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

that worked for me.
Thanks a lo

--
Anan
-----------------------------------------------------------------------
Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
View this thread: http://www.highdots.com/forums/showthread.php?t=123946

Jul 23 '05 #4

One more question on this issue.
Can I treat the req.responseText as a string an manipulate it? By tha
I mean, if I am sent two different tables to be inserted at tw
different locations, I will have to be able to access the response an
separate those two tables before inserting them at specifie
locations.

e.g. If my response is as shown below

INSERT IN PARENT NODE: 'FORM'
<table id="mytable">
...
...
</table>

INSERT IN PARENT NODE: 'DIV'
<table id = "yourtable">
...
...
</table>

Can I access it via 'for' loop or any other method so that I ca
extract each table using some code in javascript?

Anan

--
Anan
-----------------------------------------------------------------------
Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
View this thread: http://www.highdots.com/forums/showthread.php?t=123946

Jul 23 '05 #5

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

Similar topics

3
by: mr_burns | last post by:
Hi, I am using the following function to access a nodes value from an XML file. It works fine until it discovers a empty tag. I would like to have the option of leaving some tags empty for my...
1
by: Eric | last post by:
I am trying to figure out a good way to implement a XSLT transformation. Basically my goal is that I want to be able to ouput the following XML in a document: <chart type="pie" width="100"...
4
by: Lukasz Indyk | last post by:
hello;) i have a piece of html code, and want to replace every image on my page with this code. now i do it by replacing IMG node with SPAN node, and then setting innerHTML property of SPAN node...
5
by: Patient Guy | last post by:
In my reading of the Strict and Transitional DTD for HTML 4.0, the table row (TR) elements are contained within table section elements: THEAD, TFOOT, and TBODY. The table section elements are...
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
14
by: webEater | last post by:
I downloaded IE7 and tried out the native XMLHttpRequest support. I think there is an object in IE7 called "XMLHttpRequest" but I ask me why it is called "XML"HttpRequest. I made a request to an...
4
by: matth | last post by:
I've been working on something that deals with handling a user's selection within the DOM and I'm tripping up on one last, but crucial, detail. Forgive me for the length of the code, but my...
11
by: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= | last post by:
at the page : <http://thoraval.yvon.free.fr/Fixed_layout/import_nodes.xhtml> when importing an svg document i have to do : document.importNode(...
2
by: monsalvo | last post by:
What's so wrong with my code? This line is part of a VBScript soap client part of a DTS wich is functional in a 90 percent. strText = .responseXML.selectSingleNode("//" login "loginReturn") ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.