5

I have the below code. I want to link the XML code to a style sheet, and display the data in a table. I have linked to the style sheet but how do I display the XML data in a table?

<!DOCTYPE products SYSTEM "support.dtd">
<?xml-stylesheet href="style.css"?>

<products>
  <product>Widows XP</product>
  <product>Windows Vista</product>
  <product>Windows 7</product>
  <product>Windows Server 2003</product>
  <product>Windows Server 2008</product>
  <product>Debian Linux</product>
  <product>RedHat Linux</product>
  <product>VMware Virtulization</product>
  <product>Microsoft Hyper-V</product>
</products>

1 Answer 1

6

To display the given data in a table, use

products { display: table; }
product { display: table-cell; }

This displays the data as a one-row table. To add borders around cells, for example, add

product { border: solid 1px; }
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much. One other question how would I add a title to the table and display them in a row so that each products is listed one after the other IE the table would dispaly the title OS followed by Windows XP Windows Vista Windows 7 and so on.
If you need to add content, XSL might be a better tool, but for a simple static text, you can use generated content, e.g. products:before { display: table-cell; content: "OS"; font-weight: bold; border: solid 1px;}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.