stockoverflow
stockoverflow

Reputation: 1457

How to embed XML using server side only?

Using this example: http://www.w3schools.com/xml/tryxslt.asp?xmlfile=simple&xsltfile=simple

I have three files:

Currently, I only know how to display individual .xml files on my browser by adding:

<?xml-stylesheet href="myxsl.xsl" type="text/xsl" ?>

How would I go about displaying data from the .xml file into an already built HTML page? My conditions are:

  1. No Javascript allowed.
  2. No frames.
  3. Visitor is not allowed to see .xml file

Which I suspect leads to SERVER side processing (I'm using a WAMP server). Any help here? I'm not an experienced XML or web person, please dumb it down for me ;)

EDIT: I only need to do selects, for loops and sorting. So basic XSLT stuff, I can understand.

Update: If I may, my working solution:

# START XSLT
$xslt = new XSLTProcessor(); 
$XSL = new DOMDocument(); 
$XSL->load('hello.xsl'); 
$xslt->importStylesheet($XSL); 

# LOAD XML FILE 
$XML = new DOMDocument();
$XML->load('hello.xml');

#PRINT 
print $xslt->transformToXML($XML); 

Upvotes: 1

Views: 331

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

You could perform the XSLT transformation of the XML file on the server and spit HTML to the client. Here's an article which illustrates the concept using PHP.

Upvotes: 2

Related Questions