playMaker

Author Topic: [Solved] String in Xml and Datamaker  (Read 6291 times)

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
[Solved] String in Xml and Datamaker
« on: June 29, 2015, 10:28:22 AM »
Hello ,
I AM trying to get a string from the web (as an xml format) using WWW object and save it text to a variable ,
Then using Datamaker action [get node properties] accessing this string variable

The problem is no matter what I do and play with settings it dont work . [And when I copy the content of the xml files and place them manually in the string variable it WORKS?!?]
I think because loading from the web(or local file) makes the string variable an array so get node properties cant find that pecifec node .

How can I convert a string array to string with only one line?! [I tried writing the xml file in one line it didn't work?]

Can someone help me?
« Last Edit: July 03, 2015, 02:45:36 PM by DarkSoul »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: String in Xml and Datamaker
« Reply #1 on: June 30, 2015, 11:35:19 AM »
Hi,

 do you have a link to the xml online that you are trying to get.

have you validated the xml in the first place? maybe the xml returned by the web server is wrongly formated, and or polluted with html tags? it has to be a pur text content.

Bye,

 Jean

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: String in Xml and Datamaker
« Reply #2 on: June 30, 2015, 12:15:48 PM »
I am using a local file [file:///path] using WWW]
i guess the file is vaild because i imported it into unity and accessed it by datamaker proxy .

I am getting this warning
[ text node cannot appear in this state . Line 1 , position 1 .]

It works in all ways but not getting file text from extrnal source
Because I tried the same xml content in [ variable , text assets , proxy , plain text ] All works .
But getting www.text into a variable and reading a node from that variable dont work.

Could you try it :
it is easy to get the error , create an fsm >> first state >>www object save to variable >> when done event finished >> second state add( XML GET node Properties) >> use variable >> fsm string (same variable downloaded ) >> preview --empty-- (because it isn't downloaded yet ) >> property item 0 Property [ name of the node ] >> value [string to save to]

Thanks for your time :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: String in Xml and Datamaker
« Reply #3 on: June 30, 2015, 03:33:09 PM »
Hi,

 Can you send me a package with that scene you describe? I think there is a simple misunderstanding, it all works fine, I am doing this on a daily bases, accessing xmla nd json from web servers and using xmlMaker to treat strings returned by www.

Bye,

 Jean

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: String in Xml and Datamaker
« Reply #4 on: June 30, 2015, 05:25:24 PM »
Here you are .
And thanks for the help .

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: String in Xml and Datamaker
« Reply #5 on: July 03, 2015, 02:34:19 PM »
I solved my problem  8)
Replace try in the [FsmXmlSource.cs] with this and all should work fine

Code: [Select]
try{
System.IO.StringReader stringReader = new System.IO.StringReader(source);
stringReader.Read();
System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stringReader);
xmlDoc.LoadXml (stringReader.ReadToEnd());
}
Thank you for yor help .. :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [Solved] String in Xml and Datamaker
« Reply #6 on: July 07, 2015, 12:44:15 AM »
Hi,

 Thank you very much for this, I would have never encountered this myself I guess because it's the format of the string in the text file itself that is the problem,

However, I am not going to implement it in Xml, because this is really specific to your source, and so I created a custom action that you should run prior loading from  a stirng, and that custom action will work for any string.

I have put the action on the Ecosystem, it's called GetStringWithoutBOM. CAn you try this and tell me if it works ok?

 
Bye,

 Jean

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: [Solved] String in Xml and Datamaker
« Reply #7 on: July 07, 2015, 04:40:46 AM »


Acutely After posting that my problem is solved , I realized tbat after changing this I couldn't read other format at all[ Plain text , Variable , Proxy ] it kept giving me errors it is like I fixed something and ruined the others >_<  ???

So I played around with code  and I solved all of the above problems by doing this : ;)
In the FsmXmlSource try catch function :
Code: [Select]
Try {
Keep it as original
}
catch {
System.IO.StringReader stringReader = new System.IO.StringReader(source);
stringReader.Read();
System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stringReader);
xmlDoc.LoadXml (stringReader.ReadToEnd());
}


You could just change this in Datamaker and it should work for all the problems I encountered.
 ;D


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [Solved] String in Xml and Datamaker
« Reply #8 on: July 07, 2015, 05:37:59 AM »
Hi,

Yeah, that's exactly what I encountered as well, and I think this case deserves to be covered broadly, because it will give problems outside XmlMaker as well, hence why I made that custom action so that you can get a clean string in any situation, not just within xmlMaker.


Bye,

 Jean

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: [Solved] String in Xml and Datamaker
« Reply #9 on: July 07, 2015, 06:28:11 AM »
Oh , so it cleans string in any situation ,Wow that would be really helpful  ;)
Thanks Jean ,

I was Just wondering when is demo for datamaker is going to be online , I am having a problem understanding all the other actions Requirements a demo would realy clear that confusion , the only two actions that I used and understood were [ Get xml property , and select a single node]  the others I didn't , I am not expert at xml [not even advanced]

Could you help me  :) ?

Thanks in advance.
« Last Edit: July 07, 2015, 06:44:18 AM by DarkSoul »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [Solved] String in Xml and Datamaker
« Reply #10 on: July 07, 2015, 07:15:14 AM »
Hi,

Yeah, that action actually only remove the BOM if detected, so it's safe to always parse your string with that action, then you are always safe.

 I know, it's dragging on, but my current latest version of XmlMaker relies on 1.8 beta... so as soon as it's out, I'll publish the whole ( and the current version of XmlMaker won't work with previous version of PlayMaker, so it will mandatory to update xmlMaker when moving to 1.8)

Bye,

 Jean