3.0 beta 2

get xml nodes PLEASE HELP! :)

How do I make an array that contains the text inside a specific tag name of an XML file.

I know i must use table.getXML() and something like selectNode() but I can't seem to get an answer from the forums.

Please Help me.

March 23,
Here is the modified table.response method which builds an array of text from the first column and assigns it to the grid row selector -

table.response = function(xml){


        var array = [];
        var max = this.getCount();
        var row, col = 0; // take data from col 0

        // build array of values from col 0
        for (row = 0; row < max; row++){
            array[row] = this.getData(col, row);

        if (this.$owner) {

I think if you need a solution which works in both IE and FF then its easier defining additional table column with XPath and use table.getData(col, row) method.
Alex (ActiveWidgets)
March 23,
Just want to add that you can use any complex XPath to specify where your column data is, for example

@attributeName - get value of an attribute
elementName[@attrName='someValue']/@anotherAttr - get anotherAttr from the child node of an elementName where attrName = someValue :-)

See examples -

Alex (ActiveWidgets)
March 23,
WOW, The XPath is very clear to me now thank you.

But this example still didn't work for me, i'm using FF (until i get a decsent demo made)?

So you are saying, make another table column with XPath (for instance @name) using:
table.setColumns(["@name", ...'grid data columns'....]);

Then make the selectors by:
//for all rows

But won't this now display the new '@name' column in my grid as the first column??
March 23,
Oh wait,
i can do it like this:

table.setColumns([...'grid data columns'....,"@name"]);  
//...do selector stuff here...
grid.setColumnCount('one less than #of table columns');

and the last column wont be displayed correct?
March 23,
yes, exactly!
Alex (ActiveWidgets)
March 23,
what about say if i needed and update time....so the xml was
<updtime>"March 23, 2006"</updtime>

Can I pick out the updtime as a variable just to write it to a <div> tag? Without having updtime as a row. (even if it was an attribute of <xml>!)
March 23,
You can do something like -

var node = table.getXML().documentElement.childNodes[1];
var text = AW.ie ? node.text : node.textContent;

It might be childNodes[1] or childNodes[0] depending whether you have anything between <xml> and <updtime>. Also IE and FF treat whitespace differently, so I would still define a column with XPath to avoid all this (XPath = "/updtime" or maybe "//updtime" to be sure :-)
Alex (ActiveWidgets)
March 23,
Thanks very much.
March 24,

This topic is archived.

See also:

Back to support forum


Version 2

Looking for AW 2.6 ?
The old site is here.