Parsing xml

Michael Mantkowski michaelj at clientrax.com
Mon Nov 12 11:11:36 EST 2018


Hi Arnaud,

I am sure there are several ways to go about creating an XML file based on
the complexity of what you need.  Below is a very simple method I have to
create a list of Inventory Items for a 3rd party service that our clients
can subscribe to.

Whenever I need to support a vendor's requirements I have them send me a
template XML file of what they need then break it done into the most
efficient way to recreate it substituting our data where needed.  In this
case I needed to account for special characters that could appear in the
inventory items descriptions and escape them out before sending the XML.

Hope that helps.

Michael

;  Make Products XML Text

;  Get Inventory List
Begin reversible block
    Set current list lvInventoryList
    Set main file {INVENT}
End reversible block
Define list {INV_RSN,ITEM_NO,INV_DESC,InvMfgBarCode}
Set search as calculation {(InvDiagItem=0)&(InvSrvInv=1)}
Build list from file on ITEM_NO (Use search)

Calculate lvProducts as ''
;  Add Header
Calculate lvDateTime as con(jst(#D,'D:y-M-D'),' ',jst(#D,'T:H:N:S'))
Do method ----getNewGUID Returns lvGUID
Calculate lvProducts as con(lvProducts,'<?xml version="1.0"
encoding="utf-16"?>',kCr)
Calculate lvProducts as con(lvProducts,'<syncclinicproducts
syncdate="',lvDateTime,'" syncguid="',lvGUID,'"
clinicservername="',ctComputerName,'">',kCr)
Calculate lvProducts as con(lvProducts,'  <clinic
clinicguid="5408d8d5-864b-4560-8b61-b62cd263a530" clinicname="',P_NAME,'"
/>',kCr)
Calculate lvProducts as con(lvProducts,'  <products>',kCr)
For each line in list from 1 to #LN step 1
    Load from list
    ;  Add Line Items
    Calculate INV_DESC as replaceall(INV_DESC,'&','&')
    Calculate INV_DESC as replaceall(INV_DESC,'<','<')
    Calculate INV_DESC as replaceall(INV_DESC,'>','>')
    Calculate INV_DESC as replaceall(INV_DESC,"'",''')
    Calculate INV_DESC as replaceall(INV_DESC,'"','"')
    Calculate lvProducts as con(lvProducts,'              <product
name="',INV_DESC,'" barcode="',InvMfgBarCode,'" id="',INV_RSN,'"
displayid="',ITEM_NO,'" hospitalid=""',' />',kCr)
End For
;  Add Footer
Calculate lvProducts as con(lvProducts,'  </products>',kCr)
Calculate lvProducts as con(lvProducts,'</syncclinicproducts>',kCr)

Quit method lvProducts

*********************************************************************
Michael Mantkowski
ClienTrax Software
1-614-875-2245
*********************************************************************


-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> On Behalf Of A
Blanchard via omnisdev-en
Sent: Monday, November 12, 2018 11:00 AM
To: Omnisliste <omnisdev-en at lists.omnis-dev.com>
Cc: A Blanchard <infomni at yahoo.fr>
Subject: Parsing xml

Hello
I need to generat xml file for a customer using OS$8.0.3 Is it possible to
have an example ?
Thank you very much ?
Arnaud Blanchard
_____________________________________________________________
Manage your list subscriptions at http://lists.omnis-dev.com Start a new
message -> mailto:omnisdev-en at lists.omnis-dev.com 




More information about the omnisdev-en mailing list