Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Ajax + XML + MySQL

Reply
Thread Tools

Ajax + XML + MySQL

 
 
bcochofel
Guest
Posts: n/a
 
      12-13-2006
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
xmlnssi="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>(E-Mail Removed)</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

 
Reply With Quote
 
 
 
 
gregmcmullinjr@gmail.com
Guest
Posts: n/a
 
      12-13-2006
I'm not a real expert on XML, but I do know that you can create an XML
document in memory in most browsers.

Microsoft uses its "Microsoft.XMLDOM" object, and I believe in Mozilla
you can simply create a new "document" (Although that I'm less sure
about). Once you have these objects you can load them up with whatever
XML you want -- presumably in your case the XML returned from your AJAX
request. You then have the XML stored on the client's machine and can
write some javascript stuff to output it as you would like.

Cheers,

Greg

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
> xmlnssi="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>(E-Mail Removed)</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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax + XML + MySQL bcochofel Javascript 1 12-15-2006 10:15 AM
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
DBD:mysql doesn't read mysql option file /etc/my.cnf file JL Perl 0 01-28-2005 03:19 AM
"Pure Python" MySQL module like Net::MySQL Ravi Python 6 07-21-2003 06:53 PM



Advertisments