473,383 Members | 1,859 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.

Ajax + XML + MySQL

Hi, I'm using Perl CGI and HTML::Template to generate the following
XML:
----------------------------------------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xml" href="RR.xsl"?>
<!-- $Id: template.xml,v 1.5 2006/12/11 11:13:30 bcochofel Exp $ -->
<RR
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://cochofel.sytes.net
~bcochofel/iweb/files/RR.xsd">
<Request>
<url>/~bcochofel/iweb/cgi-bin/getmysites.cgi</url>
<session>
<user>g...@cochofel.net</user>
</session>
<query>
<!-- o campo parametro pode ter varias ocurrencias -->
<param name="sort" value="asc" />
<param name="field" value="" />
</query>
</Request>
<Response>
<sites>
<site url="http://www.google.com">
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="http://www.google.com/webhp?complete=1">
<tag name="ajax" weight="25" />
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="https://webmail.fe.up.pt">
<tag name="email" weight="20" />
<tag name="feup" weight="20" />
</site>
</sites>
</Response>
</RR>
--------------------------------------------------------------
The Response element gets information from a MySQL DB and this is only
an example.

I'm creating a XSL file to transform this XML output in XHTML with the
results in a table, something like:

----------------------
| URL | TAG | WEIGHT |
----------------------

One URL can have several TAGS. URL is an attribute of the element
site.

What I want his to let the client click on the table tittle (url, tag
or weight) to sort the elements using that field, if the elements are
already sorted with that field then the order is toogle (ascending
and descending).

I want to do this in the client side using Ajax but I can't figure out
how to do this. How can I get the XML elements without querying the
MySQL server again? Can I do this? Does javascript has some object to
retrieve XML elements like this?

I'm using CGI::Ajax, a Perl module, but if I use this I'll have to
querie MySQL server again to resort the elements (at least I think I
have to...)

Can someone point me out some kind of solution to this? I'm a newbie
in using Ajax and XML.

Thanks,
Bruno

Dec 13 '06 #1
1 1721
Ok, I know I can use DOM to access the XML elements and attributes
(with var x=xmlDoc.getElementsByTagName("sites");)

I want to sort <siteby url, tag/weight (inside the <site>) using
Ajax.
How can I sort by tag name attribute or tag weight attr, childs of
<site>?
Can I sort my x var like this or do I have to do some kind of
manipulation?

I'm thinking of calling a function (inside an href on the table <th>
elements) an pass a parameter to tell witch <thwas clicked, using
onClick event. I need to toggle the sorting method if the same <thhas
clicked, changing from ascending to descending...

Can I use this?

bcochofel wrote:
Hi, I'm using Perl CGI and HTML::Template to generate the following
XML:
----------------------------------------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xml" href="RR.xsl"?>
<!-- $Id: template.xml,v 1.5 2006/12/11 11:13:30 bcochofel Exp $ -->
<RR
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://cochofel.sytes.net
~bcochofel/iweb/files/RR.xsd">
<Request>
<url>/~bcochofel/iweb/cgi-bin/getmysites.cgi</url>
<session>
<user>g...@cochofel.net</user>
</session>
<query>
<!-- o campo parametro pode ter varias ocurrencias -->
<param name="sort" value="asc" />
<param name="field" value="" />
</query>
</Request>
<Response>
<sites>
<site url="http://www.google.com">
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="http://www.google.com/webhp?complete=1">
<tag name="ajax" weight="25" />
<tag name="pesquisa" weight="30" />
<tag name="procura" weight="30" />
</site>
<site url="https://webmail.fe.up.pt">
<tag name="email" weight="20" />
<tag name="feup" weight="20" />
</site>
</sites>
</Response>
</RR>
--------------------------------------------------------------
The Response element gets information from a MySQL DB and this is only
an example.

I'm creating a XSL file to transform this XML output in XHTML with the
results in a table, something like:

----------------------
| URL | TAG | WEIGHT |
----------------------

One URL can have several TAGS. URL is an attribute of the element
site.

What I want his to let the client click on the table tittle (url, tag
or weight) to sort the elements using that field, if the elements are
already sorted with that field then the order is toogle (ascending
and descending).

I want to do this in the client side using Ajax but I can't figure out
how to do this. How can I get the XML elements without querying the
MySQL server again? Can I do this? Does javascript has some object to
retrieve XML elements like this?

I'm using CGI::Ajax, a Perl module, but if I use this I'll have to
querie MySQL server again to resort the elements (at least I think I
have to...)

Can someone point me out some kind of solution to this? I'm a newbie
in using Ajax and XML.

Thanks,
Bruno
Dec 15 '06 #2

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

Similar topics

7
by: Ivan Marsh | last post by:
Hey Folks, I'm having a heck of a time wrapping mind around AJAX. Anyone know of a simple, straight-forward example for pulling a simple query from mysql with PHP using AJAX? As I...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
1
by: bcochofel | last post by:
Hi, I'm using Perl CGI and HTML::Template to generate the following XML: ---------------------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?>...
1
by: rocksoft | last post by:
Hi, i have devloping web application in Asp.net and c#, i have used ajax to achieve the auto complete text box, my company using visual studio 2003, ajax auto complete text box...
6
jafarsalam
by: jafarsalam | last post by:
hi; I'm new to PHP and AJAX MySQL codes. I found a simple code for PHP and AJAX MySQL Database communication on : http://www.w3schools.com/php/php_ajax_database.asp I downloaded the code and...
4
abdoelmasry
by: abdoelmasry | last post by:
Hi Prof's im new in ajax i need some help i wanna create active web page linked to mysql database i mean .. i open my page , it will automatically view database contents
3
by: jarremw | last post by:
hello all, what i have is a modal popup control extender, i have an ajax script that saves the value of the two textboxes that are in the popup, what i am needing is a way to insert those values into...
4
kelleyvanevert
by: kelleyvanevert | last post by:
Hello everyone, This question is often asked, and I know there are lots and lots of answers that I could be using, but I just want a clear good answer. I am making a website (for playing a game...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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?
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...

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.