Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have the following XML file and its content as below:

XML
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE labels SYSTEM "\\pena-ap-008v\GSF_Test_Label\label.dtd">
<labels _FORMAT="GSF_Test_Label\1055_3122_Box_label.lwl" _JOBNAME="$JOBNAME$" _PRINTERNAME="$PRINTERNAME$">
<label>
<variable name="CustAssNumber">$CustAssNumber$</variable>
<variable name="CustP_N">$CustP_N$</variable>
<variable name="CustRev">$CustRev$</variable>
<variable name="BatchNumber">$BatchNumber$</variable>
<variable name="SerNumber1">$SerNumber1$</variable>
<variable name="DateTime">$DateTime$</variable>
</label>
</labels>



I will pass all the value into the XML file using C# codes and its content/output as below:

?xml version=\"1.0\" encoding=\"UTF-8\"? !DOCTYPE labels SYSTEM \"\\\\pena-ap-008v\\GSF_Test_Label\\label.dtd\"[] labels _FORMAT=\"GSF_Test_Label\\1055_3122_Box_label.lwl\" _JOBNAME=\"f996f9eb-f725-4e59-9e70-fab2edb57ba7\" _PRINTERNAME=\"GSFTEST\" label variable name=\"CustAssNumber\" 1053-7116 /variable variable name=\"CustP_N\" /variable variable name=\"CustRev\" /variable variable name=\"BatchNumber\" /variable variable name=\"SerNumber1\" JG130802962 /variable variable name=\"DateTime\" 19 Dec 2014 /variable /label /labels


sorry for the messiness, the above is the output that I retrieved using debug mode. After all has been done, a label should be printed out according to all the values inside the XML and the weird thing is the message "Label has been printed successfully" is prompted but the label did not come out.

Any help is appreciated. Thank you.
Posted
Updated 18-Dec-14 17:10pm
v3
Comments
George Jonsson 18-Dec-14 23:15pm    
Looks like you are using a Zebra printer.
If your actual output is what you show, it is not well formed XML, so that is probably the reason for the failure.
How do you generate the output?

1 solution

I think one problem is that you have omitted the required attribute _QUANTITY in your data.

Your XML data should look like this:
XML
<!DOCTYPE labels SYSTEM "\\pena-ap-008v\GSF_Test_Label\label.dtd">
<labels _FORMAT="GSF_Test_Label\1055_3122_Box_label.lwl" _JOBNAME="f996f9eb-f725-4e59-9e70-fab2edb57ba7" _PRINTERNAME="GSFTEST" _QUANTITY="1">
  <label>
    <variable name="CustAssNumber">1053-7116<<variable>
    <variable name="CustP_N"></variable>
    <variable name="CustRev"></variable>
    <variable name="BatchNumber"></variable>
    <variable name="SerNumber1">JG13080296</variable>
    <variable name="DateTime">19 Dec 2014</variable>
  </label>
</labels>


If you send the above XML data directly to the printer, a label should be printed.
If this is indeed for a Zebra printer, I don't recognize the extension .lwl in the _FORMAT attribute. I usually use .zpl
 
Share this answer
 
v5
Comments
BillWoodruff 19-Dec-14 0:38am    
+5
George Jonsson 19-Dec-14 0:42am    
Thanks Bill.
It was hard work to get the XML data formatted properly. The hamsters were there eating the code. :P
Jamie888 19-Dec-14 5:29am    
Thank you George, it is indeed one of the field that many will missed out. But for may case, I have added the _QUANTITY into the XML file using code behind. But I have found the solution, it is due to my label file in which I did not configure the path of a image inside the label correctly. It cant detect the correct path, that is why my label cant printed out. Anyway thanks for your effort. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900