playMaker

Author Topic: Datamaker xml xpath index issue[SOLVED]  (Read 509 times)

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Datamaker xml xpath index issue[SOLVED]
« on: July 14, 2020, 11:50:38 PM »
Hi,

I just google and notice XML xpath is using 1 as start index instead of 0. Then why "XML Get Next Node List Properties" index start counting from 0 instead of 1. Because now if I try to set node properties by using the same variable for index it will create an issue.

« Last Edit: July 15, 2020, 04:17:20 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15494
  • Official Playmaker Support
    • View Profile
Re: Datamaker xml xpath index issue
« Reply #1 on: July 15, 2020, 02:48:43 AM »
Hi,

 This is a mental gymnastic that you will need to master.

C# convention for a list indexing is zero based
Xml convention for a list indexing is one based.

so when you want to access the first item using an xpath query you will need to put 1

but if you save several items in an FsmArray or ArrayList, then your first item will have its index at 0

keep two different variables for your indexing, one for build xpath queries and one for accessing c# arrays and lists, and when you increment your indexing, have a state that always set the c# indexing as the xpath indexing - 1 ( or vice versa)

It was a dileam for me when I created ArrayMaker and decided to go with the convention, so within c# environment, all is zero based, and in xpath queries it's not, which means that your xpath query as is will work outside Unity shoudl you want to test and create xpath queries using online editor ( which I do almost always for complex queries)

Bye,

 Jean

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: Datamaker xml xpath index issue
« Reply #2 on: July 15, 2020, 03:51:30 AM »
I see, Thanks Jean.. I manage to solve it by using different index variable.