Some Examples Using CSS Styling

If your XML data is structured as you want to display it, you can effectively use CSS to display XML content.

Listing 13.1 shows a CSS style sheet to display heading information in red and paragraph text in a smaller, black font.

Listing 13.1. Reports.css: A CSS Style Sheet to Display Reports Stored in XML
header{font-family:Arial, sans-serif; 
         font-size:18; 
         color:blue;} 
content{ {font-family:"Times New Roman", serif; 
         font-size:12; 
          color:black;} 

The XML source document is shown in Listing 13.2.

Listing 13.2. Reports.xml: A Brief XML Data Store of Reports
 <?xml version='1.0'?> <?xml-stylesheet href="Reports.css" type="text/css" ?> <Reports> <Report> <header>Some interesting report</header> <content>Some fascinating ...

Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.