# Suggestions for Turning Strings to specific XML or ZPL Code

**URL:** <https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795>\
**Category:** General\
**Created:** [29 April 2025 07:02 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795 "2025-04-29T07:02:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaVizzey](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@DaVizzey](https://discourse.nodered.org/u/DaVizzey)\
**Post date:** [29 April 2025 07:02 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/1 "2025-04-29T07:02:07Z")

</div>

Hi There!

I've gotten a task to send information to a label printer that a customer has purchased for a project,  
The issue is it can only handle two languaged, XML and ZPL. I am not at all familiar with those and i am unsure how i can turn a string with the Label information into those formats. I've asked the Supplier of the Printer on this and i only got some vauge answers, i'll attach the answers i got at the bottom. If anyone here got some suggestions or have dealt with something like this before then i'd be happy to learn!

````auto
XML Answer: 
<?xml version="1.0" standalone="no"?>
<labels _FORMAT="E:kleinaldi.ZPL" _QUANTITY="1" _PRINTERNAME="ZDesigner for Developers - Generic Printer 200dpi" _JOBNAME="Test">
    <label>
        <variable name="Grades">L</variable>
        <variable name="MHDdatum">99999</variable>
        <variable name="Kuhldatum">99999</variable>
        <variable name="MHDdatumATC">999999</variable>
        <variable name="Producer1">1-DEF-99999</variable>
        <variable name="Producer2">2-DEF-999999</variable>
        <variable name="Bahn">99999</variable>
    </label>
</labels>```

ZPL Answer:

```CT~~CD,~CC^~CT~
^XA
^DFE:kleinaldi.ZPL^FS
^LT16
^PON
^LH0,0
^XA
^XFE:kleinaldi.ZPL^FS
^CI28^FN1^FH\^FDL^FS^CI27
^CI28^FN2^FH\^FD02.09^FS^CI27
^CI28^FN3^FH\^FD27.08^FS^CI27
^CI28^FN4^FH\^FDGEF000209^FS^CI27
^CI28^FN5^FH\^FD1-DE-12345^FS^CI27
^CI28^FN6^FH\^FD2-DE-1500603^FS^CI27
^CI28^FN7^FH\^FD1^FS^CI27
^PQ1,0,1
^XZ

````

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [29 April 2025 08:51 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/2 "2025-04-29T08:51:59Z")

</div>

Something like this??

 ![IMG20240404154057](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e2fe39e2728a225abfb80204ebaa126c415ed4a4.jpeg)

What I did is assign the xml variables to global variables in node-red (global.set)  
then send the ZPL code to the printer with the delimited global.get

Hint: Zebra printers use port 9100 for ZPL so use a TCP node to send your code to it

if your not sure I can post my ZPL code for you

---

<div class="post-metadata">

**Author:** ![DaVizzey](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@DaVizzey](https://discourse.nodered.org/u/DaVizzey)\
**Post date:** [29 April 2025 10:49 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/3 "2025-04-29T10:49:08Z")

</div>

Something like that yes, I am not sure if they will be using that many variables as you got but i'd love to take a look at how you did it 🙂

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [29 April 2025 12:26 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/4 "2025-04-29T12:26:04Z")

</div>

go here [Labelary Online ZPL Viewer](https://labelary.com/viewer.html) and design your label

copy and paste the ZPL code into a function node sending the code as the payload  
if you want variables you can in use node-red globals like this

```auto
msg.payload = "^XA ^CFA,30 ^FO50,300^FDTicket Number: "+global.get(Ticket)+"^FS ^FO50,330^FDRego:"+rego+"^FS ^FO50,360^FDColour: "+color+"^FS ^FO50,390^FDMake: "+make+"^FS ^FO50,420^FDModel: "+model+"^FS ^FO50,450^FDDate/Time: "+datetime+"^FS ^FO50,480^FDJob Origin: "+originsub+"^FS ^FO50,510^FDTime Printed: "+timeprinted+"^FS ^FO50,540^FDNotes: "+global.get(notes)+"^FS ^CFA,32 ^FX Third section with bar code. ^BY5,2,270 ^FO100,590^BC^FD12345678^FS ^FO50,950^FDRelease Date: "+global.get(release)+"^FS ^XZ"
return msg;

```

---

<div class="post-metadata">

**Author:** ![DaVizzey](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@DaVizzey](https://discourse.nodered.org/u/DaVizzey)\
**Post date:** [29 April 2025 12:31 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/5 "2025-04-29T12:31:27Z")

</div>

i will try that!

Just a question about this, i forgot to mention that we are going to take the variables for a SQL Database, so they will be ever changing, not staying the same as this printer will handle boxes coming from 4 different zones that will run different orders, but this would still work? 🙂

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [29 April 2025 12:36 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/6 "2025-04-29T12:36:16Z")

</div>

Sorry mate... Im not sure of your workflow.  
I think your saying the data changes so therefore your labels have dynamic values?  
You will need to work out a print queue and work out a way to flag that the label has been printed as well

---

<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:** [28 July 2025 12:36 UTC](https://discourse.nodered.org/t/suggestions-for-turning-strings-to-specific-xml-or-zpl-code/96795/7 "2025-07-28T12:36:21Z")

</div>

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