I have multiple pages with the same information on them (forthcoming events information), and when that information needs to be changed i have to change every page which takes time. I was wondering if XML can be used to change the information on the pages by editing one central XML file, which will save me alot of time and hassle when updating the site. I have never done any work with XML before, however i have a good understanding of html and know a little javascript.

Please be aware that the information will have to be displayed in a html file. I would use asp and a database to do this, however my webhosting service will not alow the use of asp.

If anyone can give me a few tips on how this can be done it would be greatly appreciated.

Thanks for your time,

NuGG

You should look into XML Stylesheet Language Transformations (XSLT for short).

http://www.w3.org/TR/xslt ...this is a good reference
http://www.w3schools.com/xsl/ ..and this is a good introduction

I would advise building the pages using an offline XSLT processor, as client side (browser) XSLT processors are at best; bad.

EDIT: Or, you could use the PHP XSLT module. IF it's installed on your server.

I make alot of pages using offline XSLT processors (Xalan + Xerces) to create static HTML pages - but they are command line tools, and you need to understand XSL to use them...

For learning, you can create XML files, link them to XSL stylesheets and test them in certain browsers (Internet Explorer and Firefox) bear in mind, that the browser is doing work that is conventionally regarded as a "server side job", and that has a number of implications, the biggest I guess is that some browsers (i.e. Opera) don't have XSLT processors, and search engines can't make head or tail of your pages.

If you need any help when you're using XSL (setup, nuances, etc) let me know, I've been using it for a while now; for pages that are too static to be considered dynamic and to dynamic to be considered static.

Do be advised that on the fly XSLT transformation can be very slow, unless you take care to cache the precompiled XSLT files between invocations.

I've done testing for that in the past.
I've actually written a system doing as Matt suggests in Java, using XSLT on a fairly large scale to process dynamically generated XML into html output (and some things into PDF using XSL:FO).

Without caching the compiled XSLT files between requests the request/response cycle was several orders of magnitude slower as compared to the situation after I had implemented such caching.
The compilation stage was that slow, the actual processing itself was extremely fast.

TransformerFactory tFactory = TransformerFactory.newInstance();
      // Get the XML input document and the stylesheet.
      Source xmlSource = new DOMSource(xmlInput);
      Source xslSource = new StreamSource(xslFile);
      // Generate the transformer.
      Transformer transformer = tFactory.newTransformer(xslSource);
      // Perform the transformation, sending the output to the response.
      transformer.transform(xmlSource, new StreamResult(out));

You will want to cache the Transformer here in some way and reuse it.
In the final version of that system I used a simple HashMap using the filename of the XSLT file as a key.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.