playMaker

Author Topic: DataMaker Xml xPath and Json [ECOSYSTEM] [FEBRUARY 2022]  (Read 55403 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
DataMaker Xml xPath and Json [ECOSYSTEM] [FEBRUARY 2022]
« on: November 16, 2012, 07:29:24 AM »
[EDIT] NOW on the wiki: https://hutonggames.fogbugz.com/default.asp?W1133

[EDIT] Also available on the Ecosystem

Hi,

 Ok, I have an xml reader with a first action to select a node using Xpath! it's very very powerful!! Many features need to be added like being able to select multiple nodes, and output them into ArrayMaker for example, but for now this hilite the ease of use and power and is already very useful as is actually!

 basically it works like this:

1: create a DataMaker Xml Proxy and point to a text resource in your assets
2: then use the action "XPath Select Single Node" and point to that proxy to use xpath queries on that resource.

-- Xpath wildcard system
instead of letting you just input a string, I have created a simple wildcard format that allow you to define places in the xpath query that are flexible and points to FsmSTring variables.

in the sample provide, the xPath looks like
Code: [Select]
content[@type='%%0%%']
the action has defined one XPath variable for an FsmString, to %%0%% will be replaced by whatever is defined there

-- Result
The innerText is of course available, but I go much further then that
you can access any number of properties
-- attributes ( that is when you define a property starting with "@")
-- innerXml using again XPath, if your property starts with / then it will be processed as an XPath query locally on the selected node ( this is important to be aware of that, because I prepend a "." to make that path be really locale, else it will search from the document root, which is not what we want here)
-- direct child nodes innerText. simply reference the name and its inner Text will be returned

 Your first stop is to read this:
http://msdn.microsoft.com/en-us/library/ms256471.aspx

If you need some of these XPath not yet supported, let me know, the play is to support XPath fully anyway.

 Have fun, Any questions and suggestions or trouble, don't hesitate.

 Jean
« Last Edit: February 18, 2022, 02:08:16 AM by jeanfabre »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: DataMaker Xml and xPath alpha version
« Reply #1 on: November 17, 2012, 08:20:03 AM »
awesome, this is just perfect for a laguage system!
However, do you know a way to make editor classes work with this (with PlayMaker in general). It would be amazing to actually be able to create and move files at runtime.

Cheers,
kiriri
Best,
Sven

Drunkenoodle

  • Playmaker Newbie
  • *
  • Posts: 25
Re: DataMaker Xml and xPath alpha version
« Reply #2 on: November 17, 2012, 02:59:45 PM »
Just had a bit of a tinker with what you've come up with and, man, that is utterly awesome. Great job Jean!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: DataMaker Xml and xPath alpha version
« Reply #3 on: July 31, 2013, 11:15:22 AM »
Hi,

 I made some progress on this, you can now download a more stable and powerful version on the wiki:

https://hutonggames.fogbugz.com/default.asp?W1133

It's not compatible with previous alpha version tho, but it's for the best :) it's a lot more flexible and gives you raw power!

 Bye,

 Jean

JennaReanne

  • Junior Playmaker
  • **
  • Posts: 57
    • Little Worlds Interactive
Re: DataMaker Xml and xPath alpha version
« Reply #4 on: November 21, 2013, 03:57:52 PM »
First, let me just say that this is AMAZING.  This lets me store all sorts of information and grab it on the fly to generate my levels, I can't imagine how I would do that without this tool.  So a huge thank you!

I was wondering if this is still in development?  I'd love to be able to write to XML files as well.

Thanks Jean!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: DataMaker Xml and xPath alpha version
« Reply #5 on: November 28, 2013, 04:59:51 AM »
Hi,

 Yes, this is still in development, only very much down in the list of pending work :)

https://trello.com/c/tTJMLplH/26-xmlmaker-update

Please up vote this task so that it gets on top and processed quicker. Writing xml will be part of that update.


 bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #6 on: May 15, 2015, 08:40:16 AM »
Hi,

 New version is up, and now features

- Unity 5 support,
- Ecosystem downloadable
- proper version of ArrayMaker,
- Json support and convertion to xml ( RAW POWER!!!, any web rest api is accessible now)

Bye,

 Jean

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #7 on: June 19, 2015, 12:35:30 AM »
Hi,

I don't get how can you get the Json file at first, before using the "Convert Json String To Xml Node" Action.

What does the "Json Source" should point to?

Thank you for the help, great job! :)

Nico
« Last Edit: June 19, 2015, 12:38:49 AM by nighty9 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #8 on: June 19, 2015, 12:06:17 PM »
Hi,

 it can be any text, likely, it would come from a WWW action, or a text resource ( using "Load Resource" custom action.

this action is available on the Ecosystem, here is the link below to the original thread.

http://hutonggames.com/playmakerforum/index.php?topic=3916.0

 Bye,

 Jean

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #9 on: June 21, 2015, 06:34:11 AM »
Hey,

Thank you! I never used WWW actions with Playmaker up to now, i can see in ecosystem actions like WWW POST; is this can be used to for example work with "Parse" using the REST Api? Then from there i get the Json file, then Resource Load, then finally the Json to XML conversion ? :)

Not sure if that's the right procedure, thank you for the help

Nicolas

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #10 on: June 22, 2015, 08:54:18 AM »
Hi,

 Indeed! this is a typical use. Most rest api will return json, and accept json.

 Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #11 on: June 22, 2015, 11:43:42 AM »
hi, i noticed that the samples are not included in the package.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #12 on: June 22, 2015, 11:44:24 AM »
hi,
i think i understand how i have to set up an xml now, but not yet how to use DataMaker and Actions for it. i made my xml like this :

Code: [Select]
<?xml version="1.0" ?>
<Upgrades>
<Prefab>
<PrefabName>Uprgrade A</PrefabName>
<Price>50</Price>
<Unlocked>yes</Unlocked>
<Sold>no</Sold>
</Prefab>

<Prefab>
<PrefabName>Upgrade B</PrefabName>
<Price>100</Price>
<Unlocked>yes</Unlocked>
<Sold>no</Sold>
</Prefab>

<Prefab>
<PrefabName>Upgrade C</PrefabName>
<Price>20</Price>
<Unlocked>yes</Unlocked>
<Sold>no</Sold>

<Prefab>
<PrefabName>Upgrade D</PrefabName>
<Price>20</Price>
<Unlocked>yes</Unlocked>
<Sold>Yes</Sold>

<Prefab>
<PrefabName>Upgrade D</PrefabName>
<Price>20</Price>
<Unlocked>yes</Unlocked>
<Sold>Yes</Sold>

<Prefab>
<PrefabName>Upgrade F</PrefabName>
<Price>500</Price>
<Unlocked>yes</Unlocked>
<Sold>yes</Sold>

<Prefab>
<PrefabName>Upgrade E</PrefabName>
<Price>400</Price>
<Unlocked>yes</Unlocked>
<Sold>yes</Sold>

<Prefab>
<PrefabName>Upgrade X</PrefabName>
<Price>400</Price>
<Unlocked>no</Unlocked>
<Sold>yes</Sold>

<Prefab>
<PrefabName>Upgrade Z</PrefabName>
<Price>50</Price>
<Unlocked>no</Unlocked>
<Sold>yes</Sold>
</Prefab>

</Upgrades>

so 1st i would like to sort those in 2 groups (sold : yes/no) and by price but only those who are unlocked.
and what will happen if 2 or more objects have the same price?
« Last Edit: June 22, 2015, 07:33:17 PM by djaydino »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #13 on: June 24, 2015, 08:25:40 AM »
Hi,

 Totally yes!

you can "Select Single Node" when you expect 1 and only 1 result, and use "Select Nodes" when you expect several, and you'll get a list of results you can iterate with getnext actions.

Check this xpath examples:

you have something like this: http://www.w3schools.com/xpath/xpath_examples.asp

Quote
/bookstore/book[price>35]/price

so you can make operations and filter the way you want indeed.

Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: DataMaker Xml xPath and Json [MAI 2015]
« Reply #14 on: June 25, 2015, 09:17:24 AM »
hi, is there any sample?

on the wiki it says that there are 2 samples but i can't find them.

on the xml result the result i got is <result>