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.
WebAPI.bdh
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. |
nOptions |
(optional)
|
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:
|
nResult | (optional)
If a variable is provided, it will receive the number of appearances of the specified content string. |
dcltrans transaction TMain var hObject : number; sParsedValue1, sParsedValue2, sParsedValue3 : string; begin 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'"); WebPageUrl("http://localhost/productsandbooks.xml"); end TMain;
<?xml version="1.0" ?> <ProductsBooks> <Products> <Product name='Product1'>This is product1</Product> <Product name='Product2'>This is product2</Product> </Products> <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> </Books> </ProductsBooks>