WebXmlVerifyNodeAttribute Function


Verifies a nodes attribute value of the nOccurrence'd document matching the sContentType. Default sContentType is text/xml. The value of the resulting X-Path query node will be verified against the sValue parameter value. The response document has to be a valid XML document for the function to work properly. If the X-Path query string contains any elements with namespace prefixes, the namespaces have to be passed in sNamespaces.

Include file



WebXmlVerifyNodeAttribute( in  sXPath       : string,
                           in  sAttribute   : string,
                           in  sValue       : string,
                           in  nAppearance  : number optional,
                           in  nOptions     : number optional,
                           in  sNamespaces  : string optional,
                           in  nOccurrence  : number optional,
                           in  sContentType : string optional,
                           in  nSeverity    : number optional := SEVERITY_ERROR,
                           out nResult      : number optional );
Parameter Description
sXPath X-Path query that specifies which XML node
sAttribute Name of the attribute of the resulting XML node that will be verified
sValue String to compare with the parsed node value
nAppearance (optional)

Value to which the actual appearance of the specified content string is compared (see nOptions)(optional). If this parameter is omitted, the specified string must appear at least once to meet the verification rules.



The verification succeeds if the actual appearance is equal to nAppearance.
The verification succeeds if the actual appearance is greater than nAppearance.
The verification succeeds if the actual appearance is smaller than nAppearance.
If this flag is set the string compare operation is case sensitive.
If this flag is set all whites paces are ignored.
Specify this option to enable caching for subsequent requests. Note that this may lead to unpredictable behaviour, because the verification may only cover certain parts (which are loaded) of a page.
If this flag is specified all server responses are scanned (even redirection responses, which are normally not displayed by a browser).
If this flag is specified, even embedded documents can be specified by the nDocNum parameter. Normally the number of a document is defined by the occurrence of the source definition in an HTML document (src=...). If this flag is specified every embedded object increases this counter, which assigns higher numbers to subsequent frames.
If this flag is specified the response header can also be verified.
If this flag is specified only the response header is verified.
Specify this flag to perform the verification on every subsequent web function. Verification functions with this flag are usually located in the TInit transaction. Call WebCancelAllRules() to disable all verification rules.
Note: The option WEB_FLAG_RULE should only be used in the INIT transaction or in combination with the WebCancelAllRules function!
sNamespaces (optional)

Namespaces that should be recognized by the XML parser. If the x-path query contains any namespace prefixes, these prefixes have to be defined in this namespace string in the way xmlns:prefix=namespace. Multiple namespaces can be defined by separating them with a blank: xmlns:ns1= 'http://www.MyCompany.com/ns1' xmlns:ns2= 'http://www.MyCompany.com/ns2'

nOccurrence (optional)

If defined, the nOccurrence'd document that matches the content type will be parsed. Default value is 1.

sContentType (optional)

Default: text/xml

Only documents of the passed content type will be parsed. If you pass a blank, all content types will be accepted.

nSeverity Optional: Severity of the error that is raised if the verification fails. Can be one of the following values:
  • SEVERITY_SUCCESS: Success; no error (numerical value: 0)
  • SEVERITY_INFORMATIONAL: Informational; no error (numerical value: 1)
  • SEVERITY_WARNING: Warning; no error (numerical value: 2)
  • SEVERITY_ERROR: (Default) Error; simulation continues (numerical value: 3)
  • SEVERITY_TRANS_EXIT: Error; the active transaction is aborted (numerical value: 4)
  • SEVERITY_PROCESS_EXIT: Error; the simulation is aborted (numerical value: 5)
nResult (optional)

If a variable is provided, it will receive the number of appearances of the specified content string.


  transaction TMain
    hObject : number;
    sParsedValue1, sParsedValue2, sParsedValue3 : string;
    WebXmlVerifyNodeAttribute("/ProductsBooks/Products/Product[2]", "name", "Product2");
    WebXmlVerifyNodeAttribute("/ProductsBooks/Products/Product[@name= 'Product1']", "name","Product1");
    WebXmlVerifyNodeAttribute( "/ProductsBooks/Books/ns1:Book", "price", "20.95", 1,0, "xmlns:ns1='http://book'");
  end TMain;

XML Document for the sample above

<?xml version="1.0" ?>
<Product name='Product1'>This is product1</Product>
<Product name='Product2'>This is product2</Product>
<Books xmlns:bookns='http://book'>
<bookns:Book price='20.95'>Lord of the Rings</bookns:Book>
<bookns:Book price='18.70'>Star Wars - Episode I</bookns:Book>