Hi,
I have this temp-table:
DEFINE TEMP-TABLE ttDestination
FIELD destName AS CHARACTER
FIELD duration AS CHARACTER
FIELD price AS CHARACTER
FIELD linkText AS CHARACTER
FIELD link AS CHARACTER.
How can I use the WRITE-XML() to get something like this:
'<?xml version="1.0" encoding="utf-8" ?>'
'<offers type="national" infoText="">'
'<destinations>'
'<destination name="Name goes here" duration="More info here" price="fr 2599:-" linkText="Click here" link="http://etcetc/" />'
''<destination name="Name goes here" duration="More info here" price="fr 2599:-" linkText="Click here" link="http://etcetc/" />'
'</destinations>'
'</offers>'
I know how to use X-DOCUMENT and things like this but it sounds easier if I could just :
1) Define the temp-table / DEFINE TEMP-TABLE...
2) Fill the temp-table / CREATE ttDestination....
3) Define the layout of the XML. / How?
4) Use WRITE-XML() to create the xml document.
Hi Jens,
You cannot define the layout of the XML document created by WRITE-XML. Your options here are to use the ABL DOM Api and X-DOCUMENT, as you mention, or use the 10.1A ABL SAX Api and the SAX-WRITER object, which should give you better performance over DOM.
Regards,
Robin Brown
Take a look in the documentation, particularly the ABL Reference for the temp-table object, buffer object and buffer-field object handles. There are a bunch of properties that will help you to structure an the result of the WRITE-XML method. Look for things like: NAMESPACE-* & XML-*. buffer-field-handle:XML-NODE-TYPE will be of particular interest.
That said, there are some restrictions on what you can do. If you need to do something more, like restructure table/field hierarchy levels, you can do that with XSLT.
If you need to go with XSLT, that means XML manipulation outside the ABL using 3rd Party tools (or Sonic ESB).
My favorite is to write ABL classes (10.1A +) that use my XML serialization framework which is also available on PSDN.
READ-XMLSCHEMA is only useful for read in from an xml document, not write out to one. It will allow you to dynamically create a temp-table or ProDataSet definition that matches the given schema. If you want to use READ-XMLSCHEMA instead of "DEFINE TEMP-TABLE", you should be able to use WRITE-XML to generate what you're looking for.
jtownsen wrote:
Aha, that basically means that I can only use dynamic style coding for the temp-tables right?
It sure would help of someone has a small example of code to show?