tags:

views:

17

answers:

2

So I'm returning xml from a web service and I get this message in the browser (firefox)

This XML file does not appear to have any style information associated with it. The document tree is shown below.

Is this a simple fix by just passing a CSS style sheet? or is the a preferred way of styling XML?

+1  A: 

The preferred way of styling XML is XSLT. And if I'm not mistaken, XSL stylesheets are what the message actually refers to.

Without any further info, I cannot suggest anything specific. If you show some of your XML and say how it should be represented, I could get you started with a basic XSL stylesheet.

Tomalak
+1  A: 

It is possible to style XML with CSS and with XSLT. Most browsers will apply both CSS and XSLT stylesheets and render the results, when the proper processing instruction is provided in the XML.

To apply CSS to an XML file add a processing instruction like this:

<?xml-stylesheet type="text/css" href="my-style.css" ?>

To apply XSLT to an XML file add a processing instruction like this:

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

If your styling requirements are more display and decoration of the XML content, rather than transformation, then CSS styling might be easier.

Check out this W3C page: How to add style to XML

Mads Hansen
Thanks good to know as well
Phill Pafford