# PLC to RPC XML v3.02

**URL:** <https://discourse.nodered.org/t/plc-to-rpc-xml-v3-02/71844>\
**Category:** Industrial\
**Created:** [8 December 2022 06:17 UTC](https://discourse.nodered.org/t/plc-to-rpc-xml-v3-02/71844 "2022-12-08T06:17:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ixdbl](https://avatars.discourse-cdn.com/v4/letter/i/6de8d8/32.png) [@ixdbl](https://discourse.nodered.org/u/ixdbl)\
**Post date:** [8 December 2022 06:17 UTC](https://discourse.nodered.org/t/plc-to-rpc-xml-v3-02/71844/1 "2022-12-08T06:17:16Z")

</div>

I am new to node red and having trouble finding where to look for an example.

I have an S7-1200 Siemens PLC hooked up to a barcode scanner.

I need to take some values off the PLC (which I have done already and am able to see values) and send them to a RPC api formatted in XML.

I have the structured XML ready but I am not sure how to format it so I can input variables from the PLC. I have a "template" but not sure if I am doing it correctly.

My trials so far:  
S7-In -\> Template (not sure how to function it here) -\> XMLRPC  
S7-In -\> Function -\> XMLRPC

The tutorials I have seen basically say structure for JSON and use XML parser, is that the best way?

Appreciate any help my Google Fu is failing me.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 December 2022 09:56 UTC](https://discourse.nodered.org/t/plc-to-rpc-xml-v3-02/71844/2 "2022-12-08T09:56:29Z")

</div>

> [@ixdbl](#):
>
> The tutorials I have seen basically say structure for JSON and use XML parser, is that the best way?

It is "a" way.

If the XML structure is static then a template can be easier.

> [@ixdbl](#):
>
> S7-In -\> Template (not sure how to function it here) -\> XMLRPC

What do you mean by "not sure how to function it here"?

The built in help of the template node provides a basic how to (and provides the mustache syntax) e.g...

Suppose you get data from PLC, then "condition it" in a change node or function node so that going into the template node is the following msg...

```auto
{
  topic: "widgets",
  payload: {
    name: "Recipe 1",
    speed: 400,
    pressure: 5.5,
    holdTime: 2500,
    coolTime: 4000
} 

```

but you need the final XML format of ...

```auto
<?xml version="1.0" encoding="UTF-8" ?>
<root>
  <name>widgets</name>
  <recipe>
    <speed>400</speed>
    <pressure>5.5</pressure>
    <hold-time>2500</hold-time>
    <cool-time>4000</cool-time>
  </recipe>
</root>

```

you could achieve it with the template ...

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<root>
  <name>{{topic}}</name>
  <recipe>
    <speed>{{payload.speed}}</speed>
    <pressure>{{payload.pressure}}</pressure>
    <hold-time>{{payload.holdTime}}</hold-time>
    <cool-time>{{payload.coolTime}}</cool-time>
  </recipe>
</root>

```

---

<div class="post-metadata">

**Author:** ![ixdbl](https://avatars.discourse-cdn.com/v4/letter/i/6de8d8/32.png) [@ixdbl](https://discourse.nodered.org/u/ixdbl)\
**Post date:** [9 December 2022 00:51 UTC](https://discourse.nodered.org/t/plc-to-rpc-xml-v3-02/71844/3 "2022-12-09T00:51:19Z")

</div>

Steve,  
Thank you. Exactly an example I was looking for that should give me everything I need to get this done. Funny I saw a similar question earlier 2-3 years ago you answered didn't expect to see you here but thankful nonetheless, appreciate the help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 February 2023 00:51 UTC](https://discourse.nodered.org/t/plc-to-rpc-xml-v3-02/71844/4 "2023-02-07T00:51:34Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
