Converting data XML sequential rows of data to tables in another XML

Hi

I have following xml which I want to convert them into different tables when it find a row with header and all following rows as table data until it finds another row with header. the xml looks like below.

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <table>
        <row>
            <header>
                <paragraph>Rank</paragraph>
            </header>
            <header>
                <paragraph>Name</paragraph>
            </header>
        </row>
        <row>
            <cell>
                <paragraph>1</paragraph>
            </cell>
            <cell>
                <paragraph>knko</paragraph>
            </cell>
        </row>

        <row>
            <header>
                <paragraph>2</paragraph>
            </header>
            <header>
                <paragraph>sample</paragraph>
            </header>
        </row>
        <row>
            <header>
                <paragraph>3</paragraph>
            </header>
            <header>
                <paragraph>third</paragraph>
            </header>
        </row>

        <row>
            <header>
                <paragraph>Leading</paragraph>
            </header>
            <header>
                <paragraph>Flight</paragraph>
            </header>
        </row>
        <row>
            <header>
                <paragraph>300</paragraph>
            </header>
            <header>
                <paragraph>junkname</paragraph>
            </header>
        </row>
        <row>
            <header>
                <paragraph>400</paragraph>
            </header>
            <header>
                <paragraph>Currency</paragraph>
            </header>
        </row>

    </table>

</root>

I wanted to convert this into 2 tables like below

<root>
    <table>
        <tr>
            <th>Rank</th>
            <th>Name</th>
        </tr>
        <tr xmlns="">
            <td>1</td>
            <td>knko</td>
        </tr>
        <tr xmlns="">
            <td>2</td>
            <td>sample</td>
        </tr>
        <tr xmlns="">
            <td>3</td>
            <td>third</td>
        </tr>
    </table>
    <table>
        <tr>
            <th>Leading</th>
            <th>Flight</th>
        </tr>
        <tr xmlns="">
            <td>300</td>
            <td>junkname</td>

        </tr>
        <tr xmlns="">
            <td>400</td>
            <td>Currency</td>
        </tr>
    </table>
</root>

I am a new to XSLT , thanks in advance for your help.

Regards
Sri

Member Avatar for FakeTales

you can do this by using PHP to get the xml data and place it into a JSON string then you can use javascript/jQuery to create a table

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.