PDA

View Full Version : multiple XML items in one list line?


sacal
04-30-2004, 11:16 AM
How do I display multiple items <tags> from an XML document in one list item?

Let’s say this is my XML file:

<dataroot>
<client ID="0001" name="Client test 1">
<project ID="INT-00104">
<projectName>Project 1</projectName>
<startDate>04/30/04</startDate>
< dueDate >05/30/04</ dueDate >
</project>
</client>
<client ID="0002" name="Client test 2">
<project ID="INT-00104">
<projectName> Project 2</projectName>
<startDate>04/30/04</startDate>
< dueDate >05/30/04</ dueDate >
</project>
<project ID="INT-00204">
<projectName> Project 3</projectName>
<startDate>05/30/04</startDate>
<dueDate>06/30/04</ dueDate >
</project>

</client>
</dataroot>

My question is: how do I display all the information about each project in one single line, inside a list? Something like:

<list>
Client test 1 - Project 1 - 04/30/04 - 05/30/04
Client test 2 - Project 2 - 04/30/04 - 05/30/04
Client test 2 - Project 3 - 05/30/04 - 06/30/04
</list>

So I can scroll through the list and click on a project to get more info about it?

Does this idea make any sense?

<list id="mylist" x="250" y="250" >
<textlistitem >
<simplelayout axis="x" />
<text datapath="dst_projInfo:/dataroot/client/@name" />
<text datapath="dst_projInfo:/dataroot/client/project/projectName/text()" />
<text datapath="dst_projInfo:/dataroot/client/project/startDate/text()" />
<text datapath="dst_projInfo:/dataroot/client/project/dueDate/text()" />
</textlistitem>
</list>

Thanks!

vfunshteyn
05-03-2004, 02:52 PM
Here's a solution (I'm not sure if there's a more elegant/efficient one):


<list width="300" id="mylist" y="250" datapath="dst_projInfo:/dataroot">
<textlistitem datapath="client/project"
text="${datapath.xpathQuery('../@name') + ' - ' +
datapath.xpathQuery('projectName/text()') + ' - ' +
datapath.xpathQuery('startDate/text()') + ' - ' +
datapath.xpathQuery('dueDate/text()')}"/>
</list>

antun
05-03-2004, 02:58 PM
I tried to do this, but got sidetracked. I think it might be because I'm just not that familiar with lists, although yes, you do have the right idea.

Is there a reason you specifically want to use the listitem component? This will get you started without it:


<canvas debug="true">
<debug y="200" />

<dataset name="ds_mylist">
<dataroot>
<client ID="0001" name="Client test 1">
<project ID="INT-00104">
<projectName>Project 1</projectName>
<startDate>04/30/04</startDate>
<dueDate >05/30/04</dueDate>
</project>
</client>
<client ID="0002" name="Client test 2">
<project ID="INT-00104">
<projectName> Project 2</projectName>
<startDate>04/30/04</startDate>
<dueDate>05/30/04</dueDate>
</project>
<project ID="INT-00204">
<projectName> Project 3</projectName>
<startDate>05/30/04</startDate>
<dueDate>06/30/04</dueDate>
</project>
</client>
</dataroot>
</dataset>

<class name="myspeciallist" datapath="" bgcolor="0xffffff"
clickable="true">
<simplelayout axis="x" />
<text datapath="../@name" />
<text datapath="projectName/text()" />
<text datapath="startDate/text()" />
<text datapath="dueDate/text()" />
</class>

<view clip="true">
<view bgcolor="0xeaeaea">
<simplelayout axis="y" spacing="1" />
<myspeciallist datapath="ds_mylist:/dataroot/client /project" />
</view>
<scrollbar />
</view>


</canvas>


-Antun