PDA

View Full Version : Xml and Tree


bsekerci
10-13-2005, 05:52 AM
Hi,

I am new to Laszlo.

I want to know how can I display an xml data in a tree.

Dataset defined like this;

<dataset name="msg_ds" src="response.xml"/>

I can create a tree using this code:

<view width="200" height="200">
<tree datapath="msg_ds:/*" showroot="false" >
<tree datapath="*" text="$path{'name()'}"> </tree>
</tree>
</view>


The problem is: I can see only name or text of a node! How can I display both?

Thank you in advance.

bsekerci

aboni
10-13-2005, 12:34 PM
I don't know if I understand you very well, but I make a small example.

Download file below!

If anything is not very clear or if it don't is what you want, post your questions again.

Best regards!
Andrew

bsekerci
10-13-2005, 11:48 PM
Thank you aboni,

That was exactly what I want.

I changed "isleaf" attribute only.



<?xml version="1.0" encoding="utf-8"?>
<canvas width="100%" height="100%">

<include href="lz/tree.lzx"/>

<dataset name="map" src="response.xml">
</dataset>

<tree datapath="map:/*" showroot="false">
<tree datapath="*" isleaf="${this.datapath.getNodeCount() == '1'}" >
<method event="ondata">
var txt = this.datapath.xpathQuery("text()"); //Node Text
var name = this.datapath.xpathQuery("name()"); //Node Attribute

if (this.datapath.getNodeText() != "")
{
this.setAttribute("text", name + " - " + txt);
}
else
{
this.setAttribute("text", name);
}
</method>

</tree>
</tree>



</canvas>