PxPlus User Forum

Main Board => Discussions => Language => Topic started by: Mike Hatfield on May 31, 2024, 01:22:48 AM

Title: Easiest way to create an XML file
Post by: Mike Hatfield on May 31, 2024, 01:22:48 AM
Hi All,

Is there a program or utility that can read file with a dictionary definition and Output it an XML file 
Thanks
Title: Re: Easiest way to create an XML file
Post by: Jane Raymond on May 31, 2024, 01:30:27 PM
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
Title: Re: Easiest way to create an XML file
Post by: Mike Hatfield on June 02, 2024, 05:19:41 PM
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
Title: Re: Easiest way to create an XML file
Post by: Mike King on June 03, 2024, 09:50:57 AM
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.
Title: Re: Easiest way to create an XML file
Post by: Mike Hatfield on June 03, 2024, 05:20:41 PM
Hi Mike,

I will try this irrespective of whether the object can handle the whole xml.
Thanks
Title: Re: Easiest way to create an XML file
Post by: Stéphane Devouard on June 04, 2024, 04:44:40 AM
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€