MC
The easiest way to read in (well formed) XML from a file is this:

<@ASSIGN request$MyDOM '<@DOM VALUE="<@INCLUDE "/directorypath/ filename">'>

To write it out use the variable in the results of a file action. The Witango Server will automatically serialise it for you. To understand the serialisation process see the following example.

Example:  Start with a 3 x 3 array with named columns:

<@ASSIGN request$MyArray '<@ARRAY VALUE="1,2,3;4,5,6;7,8,9;">'>
<@ASSIGN request$MyArray[0,1] "Qty">
<@ASSIGN request$MyArray[0,2] "Item">
<@ASSIGN request$MyArray[0,3] "SubTotal">

Now convert it to a DOM variable. We are going to use a top secret undocumented tag that has been slipped into Witango Server 5.5.009 called @ARRAYTODOM so don't tell anyone about it. ;)

@ARRAYTODOM converts an array variable to a DOM variable in memory. It checks to see if the columns are named, and if they are, will use them as the attribute names. It is a quick and simple way to convert an array variable to a DOM variable. This tag is like @SORT in that all changes are made in memory -nothing is output until you use the variable.

So convert our array to a DOM like this.

<@ARRAYTODOM ARRAY="request$MyArray">

Calling @@request$MyArray in a result window will serialise the DOM variable and the source of the page will be the text based XML representation of the DOM:

<MyArray>
  <Row id="1">
    <Qty>
      <![CDATA[1]]>
    </Qty>
    <Item>
      <![CDATA[2]]>
    </Item>
    <SubTotal>
      <![CDATA[3]]>
    </SubTotal>
  </Row>
  <Row id="2">
    <Qty>
      <![CDATA[4]]>
    </Qty>
    <Item>
      <![CDATA[5]]>
    </Item>
    <SubTotal>
      <![CDATA[6]]>
    </SubTotal>
  </Row>
  <Row id="3">
    <Qty>
      <![CDATA[7]]>
    </Qty>
    <Item>
      <![CDATA[8]]>
    </Item>
    <SubTotal>
      <![CDATA[9]]>
    </SubTotal>
  </Row>
</MyArray>


Also here is a sample taf that has a lot of small examples of using DOM, the DOM related tags and XPath with the Witango Server 5.5.009.


________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Attachment: xpath.taf
Description: Binary data



Regards

Witango Support



On 03/09/2005, at 5:58 PM, MC Tay wrote:

Does anyone has any examples of creating (output) an XML file and reading in (input) an XML file through WiTango please?

Thanks!

MC

______________________________________________________________________ __
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf


Reply via email to