playMaker

Author Topic: Get XML data from URL and store as String (Data Maker)  (Read 459 times)

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 46
  • Multimedia Designer
    • View Profile
Get XML data from URL and store as String (Data Maker)
« on: August 25, 2017, 07:37:42 AM »
Hello  :)

I am using Data Maker actions in PlayMaker and would like to get XML data located at a URL.  The URL displays the XML data in the browser without me downloading it.  (see below)



Is it possible to store this data as a String in PlayMaker?

I've tried all the actions that come in Data Maker, but none of them seem to do what I need...or maybe I'm using them incorrectly.  Please guide me in the right direction.  Thank you.

Ateam

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Get XML data from URL and store as String (Data Maker)
« Reply #1 on: August 25, 2017, 10:55:33 AM »
Hi, whith the www object you can store text form a url.

« Last Edit: August 25, 2017, 11:08:20 AM by Ateam »

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 46
  • Multimedia Designer
    • View Profile
Re: Get XML data from URL and store as String (Data Maker)
« Reply #2 on: August 25, 2017, 11:23:38 AM »
Hmmm I don't have WWW Object listed in my PlayMaker actions.  I do remember it being there a few versions ago, but it's not here anymore.  I just tried to re-import it from the Asset store and it's not there either.

How can I get the WWW object action back so I can test this out?

Ateam

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Get XML data from URL and store as String (Data Maker)
« Reply #3 on: August 25, 2017, 11:43:16 AM »
I have the last playmaker version (1.8.5) and the WWW Object is there, but here you can get it. https://drive.google.com/file/d/0B16K68NbFExZX3RHX3pyOGQ3eGc/view?usp=sharing

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 46
  • Multimedia Designer
    • View Profile
Re: Get XML data from URL and store as String (Data Maker)
« Reply #4 on: August 25, 2017, 11:56:45 AM »
Thank you.  I downloaded and imported it into my project, but it still doesn't show up in my Action Browser.  I'm guessing this is because I am working on an Android project.

Is there an Android compatible version of the WWW Object?

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 46
  • Multimedia Designer
    • View Profile
Re: Get XML data from URL and store as String (Data Maker)
« Reply #5 on: August 28, 2017, 04:05:23 AM »
Bump.  Still looking for an Android solution to the WWW Object since it doesn't work on mobile.

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 46
  • Multimedia Designer
    • View Profile
Re: Get XML data from URL and store as String (Data Maker) [SOLVED]
« Reply #6 on: August 28, 2017, 10:38:44 AM »
Figured out a solution.  Download Easy XML Parser from the Asset Store:

https://www.assetstore.unity3d.com/en/#!/content/6976

It doesn't work straight out of the box for Unity 5, but with some tweaks I was able to get it working in Unity 5 and was able to pull XML data from a URL and then manipulate those values with an FSM in PlayMaker.  Here's the things you need to tweak to fix Easy XML Parser for Unity 5:

1) Open the included "MyComponent.cs" script and rename the "public class MyComponent" to be the same name as the value you are seeking from your XML. For me, I wanted the "datavalues" from my XML document so I named my script "datavalues.cs" and re-named my public class to "public class datavalues"

2) Add "public" variables to the "MyComponent.cs" for any values you are trying to access within your respective class. In my case, the "public class datavalues" had 2 variables I wanted to access: "relay1" and "relay3". So I added these two variables to my "datavalues.cs" script by typing "public int relay1;" and "public int relay3;". That way when the datavalues.cs component script creates the instanced Game Object, it has my values already filled in.

3) You can then access these values by making a GameObject --> UI --> Text and naming it "GUI Text".  Now your values will display in the text field of the "GUI Text" Game Object and you can pull those values into Variables using the Get Property action in PlayMaker.

The asset should really be priced at $5 since you have to manually fix it to work in Unity 5, but it IS fixable if you are willing to make the changes I pointed out above.

You really have no other choice for getting real-time URL based XML values to work on Android.
« Last Edit: August 29, 2017, 12:05:17 PM by Shawn Kilian »