How do I Create a new list for each XML element

0 favourites
  • 2 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I have the following xml:

    <?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>[/code:e9510poa]
    
    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.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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()")

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)