Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

How to query a xml file and fill to an array?

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
davidhao

How to query a xml file and fill to an array?

Post by davidhao » 19 Nov 2014, 05:38

I know I can query the xml file with xpath. That's the sample xml I was using.

Code: Select all

<Data_file>
  <Game id="2221111">
    <Msg>
      <Event Event_num="110"  Msg_type="0"  
                  LocationX="0" LocationY="0" Name="" />
      <Event Event_num="111"  Msg_type="2" 
                  LocationX="10" LocationY="50" Name="James" />
      <Event Event_num="112"  Msg_type="2"
                 LocationX="0" LocationY="-50" Name="Peter" />
      <Event Event_num="113"  Msg_type="2"
                  LocationX="50" LocationY="60" Name="Martin" />
      </Msg>
  </Game>
</Data_file>
What I want achive is select all the events where Msg_type=2, then put the LocationX , LocationY, Name to an array with selected events.
For now , I use xpath with expression "//Msg/Event[@Msg_type=2]/@ LocationX", the result supposed to be :

Code: Select all

10
0
50
but what I got is:

Code: Select all

10
How can I get all the events which match the condition? And can I put thems in an string array?
Thanks for you suggestion!

Post Reply