Parses the response document with the defined content type (default: text/xml) and returns the XML node value of the passed X-Path. 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. sBuffer will receive the parsed value.
WebAPI.bdh
WebXmlParseNodeValue( out sBuffer : string, in nBufferLen : number, in sXPath : string, in nOptions : number optional, in sNamespaces : string optional, in nOccurrence : number optional, in sContentType : string optional, out nParsedBytes : number optional);
Parameter | Description |
---|---|
sBuffer | String variable that will receive the parsed XML node value |
nBufferLen | Maximum length of the string to return. If this parameter is omitted or set to STRING_COMPLETE all available data is stored in sResult. |
sXPath | X-Path query that specifies which XML node to parse |
nOptions |
(optional)
WEB_FLAG_DONT_FORCE_LOAD: 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. |
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. |
nParsedBytes |
(optional)
Number of bytes parsed into sBuffer |
dcltrans transaction TMain var hObject : number; sParsedValue1, sParsedValue2, sParsedValue3 : string; begin WebXmlParseNodeValue(sParsedValue1, STRING_COMPLETE,"/ProductsBooks/Products/Product [2]"); WebXmlParseNodeValue(sParsedValue2, STRING_COMPLETE,"/ProductsBooks/Products/Product [@name='Product1']"); WebXmlParseNodeValue(sParsedValue3, STRING_COMPLETE,"/ProductsBooks/Books/ns1:Book", WEB_FLAG_DONT_FORCE_LOAD, "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>