XMLTODYN


The XMLTODYN converts an XML expression to a dynamic array, using an optional XSL to transform.

NOTE: This function is only available in jBASE 4.1 and later.

 

COMMAND SYNTAX

XMLTODYN(XML, XSL, result)

 

SYNTAX ELEMENTS

Array = XMLTODYN(XML,XSL,result)

If result = 0 Array will contain a dynamic array built from the xml / xsl. If result <> 0, Array will contain an error message.

There is no requirement for xsl if you are reconverting from generic xml to dynarray

a = "Tom" : @AM : "Dick" : @AM : "Harry"

xml = DYNTOXML(a,"",result)

b = XMLTODYN(xml,"",result

CRT CHANGE(b ,@AM," ")

SCREEN OUTPUT

Tom Dick Harry

If passing a stylesheet in the second parameter, it performs a transform to give a different format of the array.

XML CONTENTS

<?xml version="1.0" encoding="UTF-8"?>

<mycustomer>

<firstname>Tom</firstname>

<lastname>Dick</lastname>

<address>Harry</address>

</mycustomer>

EXAMPLE

a = XMLTODYN(xml,xsl,rc)

CRT CHANGE(a,@AM," ")

XSL CONTENTS

<xsl:template match="mycustomer">

<array>

<xsl:apply-templates/>

</array>

</xsl:template>

<xsl:template match="firstname">

<data>

<xsl:attribute name="attribute">1</xsl:attribute>

<xsl:attribute name="value">

   <xsl:number level="single"/>

</xsl:attribute>

<xsl:attribute name="subvalue">1</xsl:attribute>

<xsl:value-of select="."/>

</data>

</xsl:template>

 

etc


jBC