XML loop

Discussion and feedback on Construct 2

Post » Sun Nov 03, 2013 9:33 pm

I have the XML below:

<?xml version='1.0' ?>
<test>
     <question numberQuestion=""1"">
             <option>Germany</option>
             <option>France</option>
        </question>
        <question numberQuestion=""2"">
             <option>Brazil</option>
             <option>Mexico</option>
        </question>
</test>

I want to get all the options from the question node where Its numberQuestion attribute = 2. Can I do that with a For each node?

@cvp
B
4
Posts: 26
Reputation: 277

Post » Mon Nov 04, 2013 2:34 am

Yes. Look in the xml manual entry:
https://www.scirra.com/manual/139/xml
Specifically the links about xpath, you can reference anything to loop over.

ex.
XML For each node key "/test/question[@numberQuestion=""2""]"
--- Text set text to XML.StringValue("option")
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Tue Nov 05, 2013 12:39 am

Thanks R0J0. that worked!
B
4
Posts: 26
Reputation: 277


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests