Reading XML encoding windows-1252

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
cf1flyboy
Newbie
Posts: 7
Joined: Thu Nov 17, 2016 4:21 pm

Reading XML encoding windows-1252

Post by cf1flyboy » Sat Jan 07, 2017 10:57 pm

I am getting errors reading the detail of an XML file encoded as windows-1252
In my test script I was just trying to read the first product code
Any Suggestions???

[snippet=]
LabelToVar>XML,sXML
XMLParse>sXML,/Root/Ticket,val,numBooks
XMLParse>sXML,/Root/Ticket[1]/ItemRecord,val,numBooks
XMLParse>sXML,/Root/Ticket[1]/ItemRecord[1]/ProductCode/text(),val,len
MessageModal>val


/*
XML:
<?xml version="1.0" encoding="windows-1252" ?>

<Root><Events>
</Events>
<Ticket>
<TicketFrame StoreNum="000002" />
<ItemRecord WeightedItem="0" ProductCode="00020920000000" Quantity="1" Retail="444" ExtRetail="444" MSU="1" />
<ItemRecord WeightedItem="1" ProductCode="00000000004020" Quantity="520" Retail="149" ExtRetail="77" MSU="1" />
<ItemRecord WeightedItem="0" ProductCode="00001540011263" Quantity="1" Retail="600" ExtRetail="60" MSU="10" />
<ItemRecord WeightedItem="0" ProductCode="00007310000876" Quantity="1" Retail="549" ExtRetail="549" MSU="1" />
<Media PaymentType="11" />
<TicketTotal TransactionDT="2016-12-05" TransactionTM="05:53:54" Lane="01" EmpID="23" TransID="6" TotalRetailDols="1130" TotalTaxDols="0" TotalUnits="4" />
</Ticket>
<Events>
</Events>
<Ticket>
<TicketFrame StoreNum="000002" />
<ItemRecord WeightedItem="0" ProductCode="00002840041772" Quantity="1" Retail="149" ExtRetail="149" MSU="1" />
<ItemRecord WeightedItem="0" ProductCode="00007667710033" Quantity="1" Retail="100" ExtRetail="100" MSU="1" />
<ItemRecord WeightedItem="0" ProductCode="00020003000000" Quantity="1" Retail="599" ExtRetail="599" MSU="1" />
<Media PaymentType="1" />
<Media PaymentType="1" />
<TicketTotal TransactionDT="2016-12-05" TransactionTM="05:56:32" Lane="01" EmpID="23" TransID="7" TotalRetailDols="848" TotalTaxDols="0" TotalUnits="3" />
</Ticket>
</Root>
*/
[/snippet]

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Reading XML encoding windows-1252

Post by Marcus Tettmar » Sun Jan 08, 2017 9:13 pm

ProductCode is an attribute not the text of the item. So you need to do:

XMLParse>sXML,/Root/Ticket[1]/ItemRecord[1]/@ProductCode,val,len
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

cf1flyboy
Newbie
Posts: 7
Joined: Thu Nov 17, 2016 4:21 pm

Re: Reading XML encoding windows-1252

Post by cf1flyboy » Mon Jan 09, 2017 3:58 pm

makes sense now
That works great, Thanks!!!

I had tried something similar at one point with ()
but I kept putting the text() on the end.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts