Function XMLDocSetAction() Professional

Set action code blocks for specific tags.

Syntax
XMLDocSetAction( <nDocHandle>, <cNode>, <bAction> ) --> nTagCount
Parameters
<nDocHandle>
Numeric handle of the XML document.
<cNode>
A character string defining one or more nodes in the XML document. See description below.
<bAction>
A code block to be associated with the nodes in an XML document specified with <cNode>. This code block usually calls a user-defined function which implements the action for the parser engine when it finds a matching node. The code block receives up to four parameters:
{|cTagName, xTagContent, xTagAttr, nTagHandle| ... } --> nAction 
The following values are passed to the code block:
Action code block parameters
Parameter Value
cTagName Name of the tag as character string.
xTagContent Content of XML tag as character string or NIL.
xTagAttr Two-column array holding name/value pairs for tag attributes, or NIL if the tag has no attributes.
nTagHandle Numeric tag handle.
The code block, or the user-defined function called within the code block, must return a value equivalent to a #define constant listed in ASXML.CH.
Return values of action code block
Constant Description
XML_PROCESS_ABORT Aborts execution of other action code blocks
XML_PROCESS_CONTINUE Executes next action codeblock
Return

The function returns the number of tags, or nodes, matching the string <cNode>.

Description

This function registers a code block in the parser engine and defines the nodes in the XML document for which the code block <bAction>must be evaluated. The code block usually calls a user-defined function which implements the action for the parser engine when it finds a matching node.

To explain the required syntax for <cNode>, the following XML code is used:

<?xml version="1.0"?> 

<Configuration> 

<DatabaseEngines> 
  <load>DBFDBE</load> 
  <load>NTXDBE</load> 
  <load>CDXDBE</load> 

  <build name="DBFNTX"> 
    <data>DBFDBE</data> 
    <order>NTXDBE</order> 
  </build> 

  <build name="DBFCDX"> 
    <data>DBFDBE</data> 
    <order>CDXDBE</order> 
  </build> 
</DatabaseEngines> 

<DynamicDLLs> 
  <load>MyFirstDLL</load> 
  <load>MySecondDLL</load> 
</DynamicDLLs> 

</Configuration> 

To pass the contents of the various XML tags to the action code block, the following node strings could be used for <cNode>.

<cNode>: /Configuration/DatabaseEngines/build/order 
Result: NTXDBE, CDXDBE 

<cNode>: //DatabaseEngines/build/order 
Result: NTXDBE, CDXDBE 

<cNode>: //data 
Result: DBFDBE, DBFDBE 

<cNode>: /Configuration//load 
Result: DBFDBE, NTXDBE, DBEDBE, CDXDBE, MyFirstDLL, MySecondDLL 

<cNode>: //DynamicDLLs//load 
Result: MyFirstDLL, MySecondDLL 

The first node string in this example defines a complete path to the data embedded in the <order> tags. The following examples demonstrate the meaning of the double slash. "//" is interpreted like a wildcard that matches any possible path. This means that "//" alone matches all nodes, while "/Configuration//load" matches all <load> tags appearing within the root tag of the example. In this case, "//" matches the tags <DatabaseEngines> and <DynamicDLLs>.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.