XML Formatting Tutorial
In this tutorial we look at an example of formatting an XML document with a style sheet. The example below shows an XML document containing data about members of a squash club.
<?xml version="1.0" encoding="ISO8859-1" ?>
<squash_club> <members_list>
<member_profile>
<first_name>John</first_name>
<last_name>Davies</last_name>
<sex>Male</sex>
<age>37</age>
<date_joined>20060522</date_joined>
<level>social</level>
<next_two_bookings>
<day>Monday</day>
<day>Thursday</day>
</next_two_bookings>
</member_profile>
<member_profile>
<first_name>Mike</first_name>
<last_name>Quinton</last_name>
<sex>Male</sex>
<age>28</age>
<date_joined>20060501</date_joined>
<level>league 1</level>
<next_two_bookings>
<day>Tuesday</day>
<day>Thursday</day>
</next_two_bookings>
</member_profile>
<member_profile>
<first_name>Tracy</first_name>
<last_name>Sutton</last_name>
<sex>Female</sex>
<age>26</age>
<date_joined>20060401</date_joined>
<level>social</level>
<next_two_bookings>
<day>Monday</day>
<day>Friday</day>
</next_two_bookings>
</member_profile>
</members_list> </squash_club>
Below is a style sheet used to format the display of the document.
Style Sheet: example2.css
background-color: #ffffff;
width: 100%;
}
member_profile
{
display: block;
margin-bottom: 30pt;
margin-left: 0;
}
first_name, last_name
{
color: #FF0000;
font-size: 20pt;
}
level
{
color: #0000FF;
font-size: 20pt;
}
next_two_bookings
{
Display: block;
color: #000000;
margin-left: 20pt;
}
We link the style to the XML document as follows:
<?xml-stylesheet type="text/css" href="example2.css"?>
Next we move on to the XHTML Tutorial
Have not found what you looking for, try searching Google. Simply use the search box below: