How do I Create a new list for each XML element

Get help using Construct 2

Post » Sat Nov 01, 2014 3:54 pm

I have the following xml:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
   <MANUFACTURER>Adler
      <BIKE>
         <MODEL>100 M</MODEL>
         <CC>100</CC>
         <YEAR>ALL</YEAR>
         <BATTERY>B39-6</BATTERY>
      </BIKE>
      <BIKE>
         <MODEL>250 M</MODEL>
         <CC>250</CC>
         <YEAR>ALL</YEAR>
         <BATTERY>B39-6</BATTERY>
      </BIKE>
   </MANUFACTURER>
   <MANUFACTURER>Aermacchi
      <BIKE>
         <MODEL>125 SX</MODEL>
         <CC>125</CC>
         <YEAR>ALL</YEAR>
         <BATTERY>12N7-3B</BATTERY>
      </BIKE>
      <BIKE>
         <MODEL>175 SX</MODEL>
         <CC>175</CC>
         <YEAR>ALL</YEAR>
         <BATTERY>12N7-3B</BATTERY>
      </BIKE>
      <BIKE>
         <MODEL>Ala</MODEL>
         <CC>250</CC>
         <YEAR>ALL</YEAR>
         <BATTERY>6N11A-1B</BATTERY>
      </BIKE>
   </MANUFACTURER>
</CATALOG>


What I have is a listbox that is populated by Manufacturer when the app runs.
Example:
Manufacturers:
Adler
Aermacchi
etc.

What I'm trying to do is an event that populates a second list box based on the selected manufacturer.
Example, user selects Adler
Bikes:
100 M
250 M

Have tried all sorts but cant get the bikes list to do anything.
B
3
Posts: 1
Reputation: 177

Post » Sat Nov 01, 2014 4:13 pm

I'm not sure what the problem is... however I have an XML construct that looks like the following. The trick is that I have my "base" node (in your case this would be manufacturer. I think that selection criteria is what you're missing. I may not be doing it right.. but hopefully it helps.

<?xml version="1.0"?>
<player>
<base id="1001">
<name>test123</name>
...
...


you can find the id of the node as follows when using the loop "for each node "/player/base"

node_id = XML_PLAYER.StringValue("@id")

and then you can select based on that

name = XML_PLAYER.StringValue("/player/base[@id=" & node_id /name/text()")
B
7
S
3
G
1
Posts: 184
Reputation: 1,352


Return to How do I....?

Who is online

Users browsing this forum: sean080, yiuyiu6666 and 25 guests