playMaker

Author Topic: Datamaker XML and WWWObject help  (Read 3934 times)

kdasteve

  • Playmaker Newbie
  • *
  • Posts: 5
Datamaker XML and WWWObject help
« on: December 22, 2014, 12:49:05 AM »
Hi!  I am working on creating a piece of art the changes with the actual weather in the real world. The idea of the piece is that it will change depending on time of day, current conditions, wind, precipitation and sun/moon rise/set and phase of the moon.

I'm using the Weather Underground API as my weather data source and using the WWWObject action to connect the the WU API and bring down the current weather data. I store the XML in a string variable called WUString, and I can see that I'm getting the XML from Weather Underground and it's definitely stored in WUString string variable.

I'm trying to use datamaker XML to pull data form the specific nodes in the WUString string variable and stash them into variables and that's where I'm getting stuck.   I'm new to xPath and have been playing with simple xPath XQuery Tester but am a noob at this and can't seem to get things to work - am hoping someone can help.

Here's a link to a sample Weather Underground XML output:

http://www.xpathtester.com/xpath/93fbb74aa64863d2a30371e5d1e7b2e9

Here's what I think the query is for getting the <City> (want it to return 'Portland'):

/response/current_observation/display_location/city

And I've attached a screenshot of my latest attempt at configuring XML Select Single Node to stash the value of City into string variable 'Place'.

When I run, I'm getting 'NULL' in the XML Select Single Node Preview, so assuming the query isn't working.

I'm also getting "Unable to find style '' in skin 'LightSkin' Repaint
UnityEngine.GUIStyle:op_Implicit(String)" caution in the console, but I'm not sure that's related to my issue.

Any help is much appreciated!

Steve


« Last Edit: December 22, 2014, 12:54:03 AM by kdasteve »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker XML and WWWObject help
« Reply #1 on: December 22, 2014, 03:37:50 AM »
Hi,

 Interesting. that's a great support to explain xmlMaker! Give me some time to get into this, I'll get the proper xpath and do a proper sample for this.

 Ignore the warning, it's totally harmless ( it's the editor view showing the xml that complains, something changes in Unity for its editor skin, I need to fix it) the next version will have this fixed.

Please bump this thread :) xmas is not going to help, but I'll try to do it before new eves.


Bye,

 Jean




kdasteve

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Datamaker XML and WWWObject help
« Reply #2 on: December 22, 2014, 10:11:37 AM »
Thanks Jean, very much appreciated! Let me know if I can provide any other info - I can provide the full WeatherUnderground URL with API Key, if that will help your efforts.

Cheers,

Steve

PS Another noob question -  is there something I need to do to bump the thread? :}

kdasteve

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Datamaker XML and WWWObject help
« Reply #3 on: January 06, 2015, 04:00:49 PM »
Hi Jean - Happy 2015! Wondering if you had a chance to do a sample for my question above?  Cheers, Steve

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker XML and WWWObject help
« Reply #4 on: January 08, 2015, 09:04:30 AM »
Hello, and happy new year to you and everyone :)

 ok, I made a small scene showing how you need to work this out.

basically:

you need to select the node using an xpath query, and then get one or more of its properties or attributes,

this is done using the action "Xml Select single Node" with the following xpath:

Code: [Select]
//display_location
this will get you to that node, and then in that same action you will get a property from it ( click on "get a property") and that property will be
Code: [Select]
city
store it into a string, and boom :) you have now the city property of the node "display_location". the // means get the first node. you also give it an absolute path like:

Code: [Select]
/response/current_observation/display_location
the samples goes further and save in memory the node display_location and then using the action "Xml Get Node Properties" you can further get info and even do more xpath within that node if you want to.

XmlMaker is pending for a big update when 1.8 will be out, so I only share this as a single sample, the whole package and wiki section will be updated as a whole when time will be right.

Bye,

 Jean

kdasteve

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Datamaker XML and WWWObject help
« Reply #5 on: January 10, 2015, 07:53:07 PM »
Thanks Jean - I've got it working now! Really simple.   Looking forward to the 1.8 release.  If you want help with documentation, would be happy to assist. 

Cheers,

Steve

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker XML and WWWObject help
« Reply #6 on: January 12, 2015, 01:42:57 AM »
Hi,

 Thanks. I need help to bump features, ask for use case, and find issues, so you have been already helping a lot.

If you want to make videos on use cases like this ( I will do a series once 1.8 is out when things to stabilize), but if you want to share screencasts or docs, tips and tricks, don't hesitate, the forum is meant for this, a thread doesn't need to be a request/issue/question but also can be some findings and tips for the record.

 Bye,

 Jean

kdasteve

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Datamaker XML and WWWObject help
« Reply #7 on: January 13, 2015, 10:33:25 PM »
Hi Jean - cool, I will put some screen shots together to further the cause.  A couple of questions for you that others may have as well:

1. What's the difference between stashing something in memory vs in a variable? Why choose one or the other.

2. Is there a reason you one would use GetNode Properties vs using Select Single Node and Getting properties within that Action?

Cheers,

Steve

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker XML and WWWObject help
« Reply #8 on: January 14, 2015, 03:03:26 AM »
Hi,

1: In a variable, you only save a string, so everytime you'll need to parse it, and that's costly. in Memory, the xmlnode is a put object oriented descriptiong, no need to parse everytime.
 
2: you have to minimize xpath request, so only perform selections on nodes and single node when it's required, and then work with Get Node proprety in your following to access more information.

 Typically, select a book using xpath once, and then depending on the book or what the user wants to know from that book use get Node Properties instead of reselecting the book usinbg xpath again and again.

 

Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Datamaker XML and WWWObject help
« Reply #9 on: July 28, 2016, 08:57:08 AM »
This is really useful Steve!

I am seeking to implement a XML feed into my app and Im going to use the example above and then record the process in a step by step. Then ill share this for others (if successful)

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker XML and WWWObject help
« Reply #10 on: July 28, 2016, 08:59:25 AM »
Hi,

Cool, ping me if you have problems with dates, i recall i created actions for rss dates format, could be usefull in your case,

Bye,

Jean