RXS_CloseDom()
This subprocedure is used to clean up after utilizing the DOM parsing API RXS_OpenDom(). 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
|
|
|
The RXS_ParseDomDS_t data structure previously initialized and used as part of RXS_OpenDom() |
Example Code
**FREE
// This example demonstrates completing a DOM parsing session by using
// RXS_CloseDom on the RXS_ParseDomDS_t datastructure originally returned
// by RXS_OpenDom. It's important to call RXS_CloseDom once DOM parsing has
// been completed to free memory used by the DOM parser.
Ctl-Opt ActGrp(*New) BndDir('RXSBND');
/COPY QRPGLECPY,RXSCB
Dcl-Ds RootDomDS LikeDS(RXS_ParseDomDS_t);
Dcl-Ds BookDomDS LikeDS(RXS_ParseDomDS_t);
Dcl-S XPath Like(RXS_Var8Kv_t);
Dcl-S Data Like(RXS_Var1Kv_t);
Dcl-S x Uns(10);
Dcl-S gXML Like(RXS_Var64Kv_t);
gXML = '<?xml version="1.0" encoding="UTF-8"?>'
+ '<bookstore xmlns:test="testnamespace">'
+ '<book category="children">'
+ '<title lang="en"><![CDATA[Charlotte''s Web]]></title>'
+ '<author>E. B. White</author>'
+ '<year>1952</year>'
+ '<price>5.99</price>'
+ '<review><text>What a great book!</text></review>'
+ '<review><text>Highly recommended.</text></review>'
+ '</book>'
+ '<book category="cooking">'
+ '<title lang="en">Everyday Italian</title>'
+ '<author>Giada De Laurentiis</author>'
+ '<year>2005</year>'
+ '<price>30.00</price>'
+ '</book>'
+ '</bookstore>';
RXS_ResetDS( RootDomDS : RXS_DS_TYPE_PARSEDOM );
RootDomDS = RXS_OpenDom( gXML );
XPath = RXS_XPath( '/*:bookstore/*:book' );
RXS_ResetDS( BookDomDS : RXS_DS_TYPE_PARSEDOM );
BookDomDS = RXS_ParseDomToDom( XPath : RootDomDS );
for x = 1 to BookDomDS.NodeCount;
XPath = RXS_XPath( '*:book[%u]/*:title' : x );
Data = RXS_ParseDomToText( XPath : BookDomDS );
RXS_JobLog( 'Title: %s' : Data );
endfor;
RXS_CloseDom( RootDomDS );
return;
Data Structures
|
|
|
|
|
Internal use only |
|
|
|
Specifies the CCSID of the XML being parsed. |
|
Specifies the CCSID the parsed data will be converted to. |
|
Specifies an IFS path to an XML file to parse instead of the Input parm. |
|
Contains the current count of XML nodes tracked by this data structure. |
|
|
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |