By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

update MULTIPLE elements of an HTML page using Ajax and XSL

P: n/a
Hi all,
I want to update MULTIPLE elements of an HTML page using Ajax. for
this reason i my response is an xml document. I want to use XSL at the
client side to update these elements. How can i achieve this?
I will be very greatefull for any help.
Have a look below
================================================== ===
Response from Server using HttpRequest Object
================================================== ===

<?xml version="1.0" encoding="UTF-8"?>
<responses>
<response id="1">
<divmy name is ivo sumelong in berlin and i will be coming to london
next week</div>
</response>
<response id="2">
<divgreat peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<response id="3">
<divgreat peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<htmlUpdateInstruction>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" >
<xsl:param name="action" />
<xsl:template match="/">
<name <xsl:value-of select="/response"/>
</name>
</xsl:template>
</xsl:stylesheet>

</htmlUpdateInstruction>

</responses>

================================================== ===
Page below to be updated
================================================== ===
<!-- <?xml version="1.0" encoding="UTF-8"?-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TODO supply a title</title>
</head>
<body>
<a onClick="ava:ajaxised()" >update page</a>
<div id="1">
TO update content from response 1
</div >
<div id="2">
TO update content response 2
</div >
<div id="3">
TO update content response 3
</div >
</p>
</body>
</html>


================================================== ===
Processing the response(my ideas)
1. Using Javascript and DOM. i could update the various DIVS
2. Using XSL(embeded in xml of server reponse) and JavaScript. This is
an Idea but
can realise it only at server side. i don't know how to go about it at
the client side.
================================================== ===
-thoughts.
1. get the embeded XSL in reponse to be used for transformation
2. use the initial html page as result of transformation
3. use the initial html page and the response (xml ) as transformation
source
4.problems writing the xsl( my idea is to loop through the reponse and
search the id, then check the html element with such and id if found
then update the content with that of the response)

I will be glad if someone can help me in any way.
thanks

Mar 15 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Thu, 15 Mar 2007 12:20:29 +0100, MORALBAROMETER <su******@gmail.com
wrote:
Hi all,
I want to update MULTIPLE elements of an HTML page using Ajax. for
this reason i my response is an xml document. I want to use XSL at the
client side to update these elements. How can i achieve this?
I will be very greatefull for any help.
Have a look below
================================================== ===
Response from Server using HttpRequest Object
================================================== ===

<?xml version="1.0" encoding="UTF-8"?>
<responses>
<response id="1">
<divmy name is ivo sumelong in berlin and i will be coming to london
next week</div>
</response>
<response id="2">
<divgreat peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<response id="3">
<divgreat peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<htmlUpdateInstruction>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" >
<xsl:param name="action" />
<xsl:template match="/">
<name <xsl:value-of select="/response"/>
</name>
</xsl:template>
</xsl:stylesheet>

</htmlUpdateInstruction>

</responses>

================================================== ===
Page below to be updated
================================================== ===
<!-- <?xml version="1.0" encoding="UTF-8"?-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TODO supply a title</title>
</head>
<body>
<a onClick="ava:ajaxised()" >update page</a>
<div id="1">
TO update content from response 1
</div >
<div id="2">
TO update content response 2
</div >
<div id="3">
TO update content response 3
</div >
</p>
</body>
</html>


================================================== ===
Processing the response(my ideas)
1. Using Javascript and DOM. i could update the various DIVS
2. Using XSL(embeded in xml of server reponse) and JavaScript. This is
an Idea but
can realise it only at server side. i don't know how to go about it at
the client side.
================================================== ===
-thoughts.
1. get the embeded XSL in reponse to be used for transformation
2. use the initial html page as result of transformation
3. use the initial html page and the response (xml ) as transformation
source
4.problems writing the xsl( my idea is to loop through the reponse and
search the id, then check the html element with such and id if found
then update the content with that of the response)

I will be glad if someone can help me in any way.
thanks
Go with your first idea. This will work in all DOM-savvy browsers.

XSLT is not designed to run in a browser. Any browser implementation will
inevitably lead to compatibility problems.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Mar 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.