Is it possible to apply style to an XML structure?

0

A while ago I did this question , and these days I thought if I could not use XML for structures, for example with a table, make the following two codes have the same behavior when interpreted by the browser:

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>
  • Is it possible to do this?
  • If yes, how?

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

    
asked by anonymous 09.11.2017 / 13:35

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:

<?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>

Font

    
09.11.2017 / 13:37