Is it possible to apply style to an XML structure?

Asked

Viewed 131 times

0

A while ago I did that question, and those days I wondered if I could not use XML for structures, for example, with a table,:

XML:

<root>
    <row>
        <col>col 1</col>
        <col>col 2</col>
        <col>col 3</col>
        <col>col 4</col>
    </row>
    <row>
        <col>col 1</col>
        <col>col 2</col>
        <col>col 3</col>
        <col>col 4</col>
    </row>
</root>

HTML:

<table>
    <tr>
        <td>col 1</td>
        <td>col 2</td>
        <td>col 3</td>
        <td>col 4</td>
    </row>
    <tr>
        <td>col 1</td>
        <td>col 2</td>
        <td>col 3</td>
        <td>col 4</td>
    </tr>
</table>
  • It is possible to do this ?
  • If yes, how?

NOTE: There is no context to insert this, it’s just curiosity.

1 answer

2


Yes you can indicate the style through :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="style.css"?>

Or else:

<?xml-stylesheet href="#style" type="text/css"?>
<root>
    <extras id="style">
    row{font-size: x-large;  color: #777777;}
    extras{ display: none; }
    </extras>
    <row>
        <col>col 1</col>
        <col>col 2</col>
        <col>col 3</col>
        <col>col 4</col>
    </row>
    <row>
        <col>col 1</col>
        <col>col 2</col>
        <col>col 3</col>
        <col>col 4</col>
    </row>
</root>

Source

Browser other questions tagged

You are not signed in. Login or sign up in order to post.