Ajax with XML and XSL

B

bcochofel

Hi, I want to update part of a XML output (generated by Perl CGI). I'm
using XSL to transform the XML.

Can I use this approach?

I need to resort the contents of a table, that gives me the results
from a query, when someone clicks on one of the names of that table.

Thanks,
Bruno
 
B

Bart Van der Donck

bcochofel said:
Hi, I want to update part of a XML output (generated by Perl CGI). I'm
using XSL to transform the XML.

Can I use this approach?

I need to resort the contents of a table, that gives me the results
from a query, when someone clicks on one of the names of that table.

Several approaches are possible:

- XSL: not my favourite, browser dependencies, client side
- TDC: only for Internet Explorer, handy, quick, propietary, the same
concept as eg VBScript, MS Help Viewer, ActiveX, etc.
- Perl: XML::Simple/XML::parser, server side, low client requirements,
solid
- Ajax: probably okay
 
B

bcochofel

I'm working with Linux, so no TDC...
I have to work only on the client side, but without XSL (I don't know
how to use XSL on the client...)
I guess I'll have to stick with Ajax. My problem his: How can I read
the elements from the XML? DOM? Don't know much about DOM.

Can I save the elements (using DOM) to an array in Javascript so them I
can resort whatever I want?
 
D

Dag Sunde

bcochofel wrote:
I'm working with Linux, so no TDC...
I have to work only on the client side, but without XSL (I don't know
how to use XSL on the client...)
I guess I'll have to stick with Ajax. My problem his: How can I read
the elements from the XML? DOM? Don't know much about DOM.

Can I save the elements (using DOM) to an array in Javascript so them
I can resort whatever I want?

That's what I would have done...

Loop through the DOM to build your JS array, and build your table
from that.
Each time the user clicks on a column heading, resort the array
and rebuild your table from JS.
 
B

bcochofel

My problem his that I have to use XSL on the server side to generate
the table.
Maybe after that I can create the JS array but I'll have something like
this (in 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>[email protected]</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>

So <site> can have several <tag> elements.
How can I create an array with JS like this? I want to sort by
site[@url] attr, tag[@name], or tag[@weight]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,007
Messages
2,570,266
Members
46,865
Latest member
AveryHamme

Latest Threads

Top