:: Home >>

XML data

Lets look how to load simple XML data into the grid.

Here is the XML (click to open):

<companies>
    <company>
        <ticker>MSFT</ticker>
        <name>Microsoft Corporation</name>
        <mktcap>314,571.156</mktcap>
        <sales>32,187.000</sales>
        <employees>55000</employees>
    </company>
    <company>
        <ticker>ORCL</ticker>
        <name>Oracle Corporation</name>
        <mktcap>62,615.266</mktcap>
        <sales>9,519.000</sales>
        <employees>40650</employees>
    </company>
...

To load and transform XML data you need an XML table model.

var table = new AW.XML.Table;

Assign a URL of the XML file.

table.setURL("/examples/data/companies-simple.xml");

By default the model looks at the documentElement as the data root. Then all child elements of the root are treated as rows and the child elements of each row node become the table cells. Exactly as this simple example looks like.

Just load the file.

table.request();

After the grid object is created

var obj = new AW.UI.Grid;
obj.setColumnCount(5);

it is assigned our new external data model.

obj.setCellModel(table);

And finally write the grid HTML to the page.

document.write(obj);

Comments

18 Mar 10
AW is undefined (1)
12 Jun 08
Column order? Alex P. (2)
13 Dec 07
Loading from xml data island and asigning row IDs Daniel Vanesse (2)
8 Nov 07
XML Data Jim Nickel (1)
7 Sep 07
Applying colors to rows and cells when loading XML Jerry Lambert (5)
30 Jul 07
when populating xml with asp, if international chars present then grid not shows data Serkan Polat (2)
14 May 07
Loading an XML string in a grid is very very slow. Piyusha (3)
6 Apr 06
Weird XML data rendering Thierry Nivelet (1)

Comments will appear on this page and in the main forum.

Documentation:

Recent changes:

2.6.4
2.6.3
2.6.2
2.6.1
2.6.1
2.6.0
2.5.0 - 2.5.6
2.5.6
2.5.0 - 2.5.5
2.5.5