playMaker

Author Topic: Get value of third sub-level from XML file by DataMaker  (Read 903 times)

JOY

  • Junior Playmaker
  • **
  • Posts: 51
  • From JOY Entertainment
    • View Profile
    • JOY Entertainment
Get value of third sub-level from XML file by DataMaker
« on: December 11, 2016, 08:31:02 PM »
Hi,

I need to get the value from the attached XML file by DataMaker. Following the tutorial, I was able to get the first sub-level (Children of <Level> one). However, I got stuck at how to get the value of its children (Children of <RankSpeeds>).
Anyone can advise?

Thanks.
« Last Edit: December 14, 2016, 02:08:51 AM by JOY »

elusiven

  • Full Member
  • ***
  • Posts: 227
  • Debt we all must pay...
    • View Profile
Re: Get value of third sub-level from XML file by DataMaker
« Reply #1 on: December 12, 2016, 02:43:46 AM »
Have a play with it here..

http://codebeautify.org/Xpath-Tester

This should give you an idea of how xpath, nodes and attributes work. I always use this to simulate results.

JOY

  • Junior Playmaker
  • **
  • Posts: 51
  • From JOY Entertainment
    • View Profile
    • JOY Entertainment
Re: Get value of third sub-level from XML file by DataMaker
« Reply #2 on: December 12, 2016, 07:55:54 PM »
Thank you elusiven.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Get value of third sub-level from XML file by DataMaker
« Reply #3 on: December 13, 2016, 12:23:26 AM »
Hi,

 have you been able to figure it out? indeed Elusiven is right, using such tool helps drafting the xpath query, else it's very tedious and time consuming to do that directly in your game.

Bye,

 Jean

JOY

  • Junior Playmaker
  • **
  • Posts: 51
  • From JOY Entertainment
    • View Profile
    • JOY Entertainment
Re: Get value of third sub-level from XML file by DataMaker
« Reply #4 on: December 13, 2016, 04:00:05 AM »
Hi Jean,

Yes the link is great. However, I got stuck as how to store all "Children" values, for example all "Level" at once instead of browsing every row of the XM file.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Get value of third sub-level from XML file by DataMaker
« Reply #5 on: December 13, 2016, 11:56:36 PM »
Hi,

 If you give a sample of the xml and the result you expect, I'll show you the xpath.

 Bye,

 Jean

JOY

  • Junior Playmaker
  • **
  • Posts: 51
  • From JOY Entertainment
    • View Profile
    • JOY Entertainment
Re: Get value of third sub-level from XML file by DataMaker
« Reply #6 on: December 14, 2016, 12:13:58 AM »
Hi Jean,

It's in the first post.

Thanks,
Anh

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Get value of third sub-level from XML file by DataMaker
« Reply #7 on: December 14, 2016, 12:32:48 AM »
Hi,

 can you paste it as text, thanks.

 Bye,

 Jean

JOY

  • Junior Playmaker
  • **
  • Posts: 51
  • From JOY Entertainment
    • View Profile
    • JOY Entertainment
Re: Get value of third sub-level from XML file by DataMaker
« Reply #8 on: December 14, 2016, 12:41:22 AM »
Hi,

Here it is.
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfLevel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Level>
    <IdLevel>1</IdLevel>
    <NameLevel>Level 1</NameLevel>
    <Scenario>0</Scenario>
  <SpeeedStart>10</SpeeedStart>
    <ChunkBossRate>20</ChunkBossRate>
    <RankSpeeds>
      <RankSpeed>
        <Distance>100</Distance>
        <Value>15</Value>
        <Reward>1</Reward>
      </RankSpeed>
      <RankSpeed>
        <Distance>500</Distance>
        <Value>20</Value>
        <Reward>1</Reward>
      </RankSpeed>
      <RankSpeed>
        <Distance>2000</Distance>
        <Value>30</Value>
        <Reward>1</Reward>
      </RankSpeed>
    </RankSpeeds>
    <ChunkActive>
      <int>1</int>
      <int>2</int>
      <int>3</int>
      <int>4</int>
  <int>5</int>
  <int>6</int>
    </ChunkActive>
  </Level>
  <Level>
    <IdLevel>2</IdLevel>
    <NameLevel>Level 2</NameLevel>
    <Scenario>0</Scenario>
    <SpeeedStart>12</SpeeedStart>
  <ChunkBossRate>20</ChunkBossRate>
    <RankSpeeds>
      <RankSpeed>
        <Distance>100</Distance>
        <Value>10</Value>
        <Reward>1</Reward>
      </RankSpeed>
      <RankSpeed>
        <Distance>200</Distance>
        <Value>15</Value>
        <Reward>1</Reward>
      </RankSpeed>
      <RankSpeed>
        <Distance>300</Distance>
        <Value>10</Value>
        <Reward>1</Reward>
      </RankSpeed>
    </RankSpeeds>
    <ChunkActive>
      <int>1</int>
      <int>2</int>
      <int>3</int>
      <int>4</int>
    </ChunkActive>
  </Level>
</ArrayOfLevel>

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Get value of third sub-level from XML file by DataMaker
« Reply #9 on: December 14, 2016, 01:38:12 AM »
Hi,

 ok, I am confused as what you want, there is no attribute or node Speed.

 do you mean you want to access all Rankspeeds?

I have anyway done this, please get the attached packaged, the scene is in PlayMaker Custom Sample/DataMaker/levels

It gets all rankspeeds values and put them into separate lists, Distances, Values, Rewards.

 I think your confusing is multiple here, so have a go and check this out, and see how each Xpath is made, the most complex being on how to get to a level given it's id:

//*[IdLevel=_0_]/.

where _0_ is a variable reference holding the level id, so this xpath say

give me any parent ( /.) from anywhere in the xml (//*) of a node "IdLevel" who's content is equal to _0_ ( 2 in the demo.

which this we know have a hold on a particular level xml.

then, we get the rankSpeeds, the xpath is:

RankSpeeds/RankSpeed

this is where thing could be confusing too, you want all 'RankSpeed' nodes, so you need to point at the place you expect them.

So yeah, here it's really a matter of learning and mastering xPAth. I whish I had a magic trick to make this easier to learn, but there isn't :) xPath is Amazing, Powerful and SOOO flexible that it's a language to leanr by itself, and experimenting is the only way I personnally found my way around that...

If the demo works for you, I'll wrap it up as a sample on the Ecosystem, Are you ol if I use your xml? I think that a real world scenario always has more impact on useful learning.

Bye,

 Jean

JOY

  • Junior Playmaker
  • **
  • Posts: 51
  • From JOY Entertainment
    • View Profile
    • JOY Entertainment
Re: Get value of third sub-level from XML file by DataMaker
« Reply #10 on: December 14, 2016, 02:09:45 AM »
Hi,

I modified the file comparing with my initial post so there is no Speed one. I edited for not make confusion.
Let me try your example and update you later. You are free to use my XML as an example.