Easiest way to create an XML file

Started by Mike Hatfield, May 31, 2024, 01:22:48 AM

Previous topic - Next topic

Mike Hatfield

Hi All,

Is there a program or utility that can read file with a dictionary definition and Output it an XML file 
Thanks
Mike H

Jane Raymond

Yes, there is way to do this if you're using PxPlus 2024, released last week.


Create a query to define the file(s) and fields. Then you can use the query definition in conjunction with the new *tools/qryexport utility to generate a Microsoft XML file that can be used to populate a spreadsheet. (It can also generate comma-separated (.csv), tab-delimited (.txt) and symbolic link (.slk) files.


Call "*tools/qryexport",queryName$,queryLib$,exportfile$[,queryopts$,show_flg$]


Here's more info on all the options:
https://manual.pvxplus.com/page/utilities/qryexport.htm
Jane Raymond
Software Developer
PVX Plus Technologies Ltd.

Mike Hatfield

Hi jane

I tried it, works well however I need to create XML for a specific EDI enabled provider.
They require the name tags on each element within the node.

I used the *obj/xml to create xml with specific name tags.
This works well for small XML string creation however I suspect the XML string it will create for my purpose will be too large for a call to handle.
What is the best way to create a large XML string?
It would be great if the obj/xml had a write to file option.
Thanks
Mike H

Mike King

Mike

While it is true that the XML object maintains the full XML in memory, you would need a very large XML for it not to be supported especially when using a 64 bit version of PxPlus.

That being said if what you are creating is a XML file with multiple sub-entries such as an XML with all invoices and details you can likely generate this yourself creating a wrapper manually and using the XML object for the sub-ordinate entires:

For example:

   PRINT (xmlfile) "<invoices>"
   oXML=new("*obj/xml" for program)
   SELECT * from "invfile"
   oXml'Set_xml("") ! Clear any prior values
  ... create the XML for the invoice
   PRINT (xmlfile) oXml'get_xml$()
   NEXT Record
   PRINT (xmlfile) "</invoices>"


This will allow you to create any size XML.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Mike Hatfield

Hi Mike,

I will try this irrespective of whether the object can handle the whole xml.
Thanks
Mike H

Stéphane Devouard

#5
MikeH

Working daily at my job with *obj/xml to handle interfaces with an e-Commerce app API, I haven't been confronted with any memory issue in the last 2 years

*obj/xml represents an XML node, so internally, every single node or subnode of your XML document is an *obj/xml instance
IIRC the powerpoints from 20+ years ago, in PVX OOP, all instances of the same class share the logic (the methods are loaded in memory only once), only the instance data (properties) is distinct.
The actual XML string is created only when you use the 'get_xml$() method

In any case, Mike's logic is the best way to go if you're worried about memory usage

My 0.02€
Stéphane Devouard
Portfolio | Work