playMaker

Author Topic: xpath roadblock  (Read 2074 times)

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
xpath roadblock
« on: May 13, 2019, 03:06:22 AM »
Hi all,

I'm relatively new to playmaker and brand new to datamaker, and I've run into a wall trying to find the right xpath into a csv file being converted to xml at runtime.

The xml that shows up in my inspector looks like this:

<Root>
  <Record>
    <Field>CSVFILE</Field>
  </Record>
</Root>

I've tried things like:
/Root/Record/Field
/Root/Record/Field/text()

Each time hit play, however, the action is disabled and the output of 'xml select nodes' action is a "not found." I'm able to see the contents of the CSV/XML file in the State editor, but can't seem to do anything with it.

Ideally, I'd like to make 2 different word randomization (get a random word/'phone a friend') buttons that auto-fill 1 text input field. These will be big data-scraped files, which I'm planning to put into a hash table. I'd also like to be able to export the player's own (not random) words from that same input field onto an xml or csv, which I can then feed back (along with multiplayer chat) into the game (and onto a webGL host site). Anyways, I'd like to use csv/xml to do this, but I'm stuck on this annoying xpath obstacle and can't figure out what's wrong. Any recommendations?

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
Re: xpath roadblock
« Reply #1 on: May 13, 2019, 12:18:37 PM »
here's a more direct way of stating above question... an online xpath generator tells me PREFIX=NAMESPACE is the proper setup. Basically I have an xml file converting at runtime from a csv. In this csv is a big list of words that I want to randomly select from when someone hits a button. Any easy way to fix the PREFIX=NAMESPACE issue?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: xpath roadblock
« Reply #2 on: May 13, 2019, 04:43:38 PM »
hi.
you can use 'Xml Select Single Node'

then set '/Root/Record'

and add a property 'Field'

see image below :




Here are some links to some datamaker tutorials :



also this tool is very useful for getting xpaths : https://xmltoolbox.appspot.com/xpath_generator.html

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
Re: xpath roadblock
« Reply #3 on: May 13, 2019, 05:30:10 PM »
Hi Djaydino,

Thank you for this quick reply! I will go through these links (I'm currently watching your youtube vid and—after my xpath searches—it makes total sense & helps alot!).

As it so happens, I just figured out a solution to my problem. I was using a text asset as a source selection and not a proxy. I should have been using a proxy, I guess, because I converted the csv file. Whoops.

Thanks again.     

Matthew Reilly

  • Playmaker Newbie
  • *
  • Posts: 20
String to Int Issue (from Re: xpath roadblock)
« Reply #4 on: May 14, 2019, 03:08:03 AM »
So, I am moving along with this randomization button but ran into another block at the "convert string to int" action that is needed to get my xml proxy file (the converted csv file) into a hash table.

I see that some people on forum have had issues with this action in the past—are these still issues? If they aren't, am I doing something wrong here?––––––––
   the "convert string to int" action isn't reading the string variable I'm giving it from
   the prior FSM (it's identical to the last variable in "xml get next list properties" / in Element O / @CSVFILE (which is the data in my xml file).
 
-OR///THIRD OPTION-
Is there a workaround other from hashes to get this data into a "random word generator" button to fill the input field (which the game will use to build a story)?
Ideally, it would be a format that also allows the game to grab players' deliberate input from a text input field & feed it into the file / webGL hosting. Ideally, I'll be trying to create a "use past input" randomizer button & also to feed game's final output (a story) onto a podcast-generator.   

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: xpath roadblock
« Reply #5 on: May 20, 2019, 04:10:12 AM »
Hi,

You should try convert String to int and if you hit an issue, report it, it should work.

As an alternative, you can create two fsmArray, one containing the keys, one containing the relative values for each keys. for a given key, get the index, and then take the value from the second array or vice versa.

else, you can convert your csv to xml and alwasy pull data from the xml, IF you don't do that in the game loop, that is, only execute xpath actions in a discrete way, a click of a button is fine, but pulling data everyframe from xpath is wrong, better cache it in arrays or hashes.

 Bye,

 Jean