playMaker

Author Topic: Write to xml in datamaker help please  (Read 1332 times)

smiffy

  • Junior Playmaker
  • **
  • Posts: 54
Write to xml in datamaker help please
« on: November 19, 2018, 06:36:11 AM »
I've got the xml reading in fine but have no idea how to use the Xml Set Node Properties action to write to it.

Say I'd like to change the colour in the below node with id objectB to green, how would I do that?
<OBJECTS>
      <OBJECT id="objectA" colour="Red" Number="123"></OBJECT>
      <OBJECT id="objectB" colour="Blue" Number="5000"></OBJECT>
</OBJECTS>
Thanks in advance,
Matt

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Write to xml in datamaker help please
« Reply #1 on: November 21, 2018, 01:01:46 AM »
Hi,

 first, are you able to select the OBJECT node with its @id "objectB" ? that's your first step, you save this node into a reference. Use the DataMaker reference browser to check the content of all your references, launch it via the menu PlayMaker/addon/DataMaker/Xml/Reference browser

Once you have this node in reference, you use the action XmlSetNodeProperties, by passing the reference, and you set one property, in this case an attribute so the property would be "@colour".

Let me know where you are in this process.

Bye,

 Jean

smiffy

  • Junior Playmaker
  • **
  • Posts: 54
Re: Write to xml in datamaker help please
« Reply #2 on: November 27, 2018, 11:51:43 AM »
Hi Jean,

So I've managed to create a single node reference.
I made a proxy for my main xml then used Xml Select Single Node, saving the result to a separate proxy object. I can set it's properties now, thanks for that:)

But now I'm struggling to get it back into the main proxy xml. I'm trying to use Xml replace node but just cant seem to get my head around the child node references.

Thanks,
Matt

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Write to xml in datamaker help please
« Reply #3 on: December 03, 2018, 01:09:42 AM »
Hi,

 there is no need to replace, the proxy will have your node being editedm, since it's the same xml in memory, only that you have different pointers for convenience ( the node references)

however for the sake of perfs, you may have to refresh the proxy, as it has to parse the xml to render it as a string. use the action "XmlProxyRefreshStringVersion" for this.

Bye,

 Jean