# RXS_CloseDom()

This subprocedure is used to clean up after utilizing the DOM parsing API [RXS_OpenDom()](https://isupport.katointegrations.com/rxs/3.2/rxs_opendom.md). It only needs to be called on the primary DOM data structure. You should not attempt to close a DOM data structure created as a result of calling RXS_ParseDomToDom().

This subprocedure must be called at the end of all DOM parsing to properly free up memory and avoid performance impacts.

## Subprocedure Prototype

### IBM i 6.1+

```rpgle
     D RXS_CloseDom    PR                  Extproc('RXS_CloseDom') Opdesc

      // The RXS_ParseDomDS_t data structure previously initialized and used as
      //   part of RXS_OpenDom()
     D  DS                                 Like(RXS_ParseDomDS_t)
     D                                     Options(*Varsize)
```


## Example Code

### IBM i 6.1+

#### Example 1
```rpgle
      *--------------------------------------------------------------
      * This example demonstrates closing DOM parsing using a RXS_ParseDOMDS_t
      *  datastructure.
      *--------------------------------------------------------------
     H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)

      /copy QRPGLECPY,RXSCB

     D OpenDomDS       DS                  LikeDS(RXS_OpenDOMDS_t)
     D RootDomDS       DS                  LikeDS(RXS_ParseDOMDS_t)
      /free
       RXS_ResetDS( OpenDomDs : RXS_DS_TYPE_OPENDOM );
       RXS_ResetDS( RootDomDs : RXS_DS_TYPE_PARSEDOM );
       OpenDomDs.InputCcsid = RXS_CCSID_UTF8;
       RootDomDS = RXS_OpenDom( gXmlResponse : OpenDomDs );
       
       gXPath = RXS_XPath( '/*:Envelope/*:Body/*:FahrenheitToCelsius' +
         'Response/*:FahrenheitToCelsiusResult' );
       
       gCelsius = %Dec( RXS_ParseDomToText( gXPath : RootDomDS ) : 11 : 7 );
       
       RXS_CloseDom( RootDomDS );

       *INLR = *ON;
      /end-free
```

## Data Structures

### RXS_ParseDomDS_t

```rpgle
     D RXS_ParseDomDS_t...
     D                 DS                  Qualified Template Inz

     D   ReturnedErrorInfo...
     D                                     LikeDS(RXS_ReturnedErrorInfoDS_t) Inz

     D   OnErrorMessageType...
     D                               10I 0

      // Specifies the CCSID of the XML being parsed.
     D   InputCcsid...
     D                               10I 0

      // Specifies the CCSID the parsed data will be converted to.
     D   OutputCcsid...
     D                               10I 0

      // Specifies an IFS path to an XML file to parse instead of the Input parm.
     D   Stmf...
     D                                     Like(RXS_Var1Kv_t)

      // Contains the current count of XML nodes tracked by this data structure.
     D   NodeCount                   10U 0

     D   NodeType                    10I 0

      // Internal use only
     D   xml@                          *

      // Internal use only
     D   doc@                          *

      // Internal use only
     D   context@                      *

      // Internal use only
     D   dict@                         *

      // Internal use only
     D   current@                      *

      // Internal use only
     D   parent@                       *

      // Internal use only
     D   Reserved                  4096A
```

