xmlTlGetTag

CAS XML Script Library

The xmlTlGetTag function retrieves the data associated with a tag (element) within the response XML returned from the xmlTlSend function.  This function can retrieve tags at the root level of an XML taglist or within sections, depending on the TagPath you provide to query the XML.

Because the response from xmlTlSend is an XMLDOM object, using the xmlTlGetTag function is only one of many ways to parse the XML.  You are encouraged to use XMLDOM methods, such as selectSingleNode and selectNodes, to query the XML in any way that is convenient for your application.

BSTR xmlTlGetTag(
  Object xmlDoc, // xmlDoc object returned from xmlTlSend
  BSTR   TagPath // Tag name or XPath to tag
)

Parameters:
xmlDoc A response xmlDoc object returned from the xmlTlSend function.  The layout of the response XML is identical to XML taglists that are sent to the server, for example, the following is the response XML from using GET_FILE_FUNCTION.

<CAS>
 <TAGLIST>
  <GET_FILE_RESULT/>
  <STATUS_NUM>0</STATUS_NUM>
  <STATUS>Operation Succeeded</STATUS>
  <CONTENT_DATA>VGV4dCB0byBh ... yIHBhZ2Uu</CONTENT_DATA>
 </TAGLIST>
 <STATUS_NUM>0</STATUS_NUM>
 <STATUS_EXTENDED_NUM>0</STATUS_EXTENDED_NUM>
 <STATUS/>
</CAS>

TagPath
This TagPath... Returns this Tag...
STATUS_NUM The STATUS_NUM tag under <TAGLIST>.
USER_NAME[2] The USER_NAME tag from the third USER_NAME section under <TAGLIST>.
MESSAGE_HANDLE[0]/RECEIVER_CSID   The RECEIVER_CSID tag from the first MESSAGE_HANDLE section under <TAGLIST>.

Return Value:
The data associated with a tag or any empty BSTR ("") if the tag is not found.

Example:
function GetMsgFile( MessageHandle, MessageFileToGet )
  {
  var Tl = xmlTlNew();
  xmlTlAddTag(Tl,"GET_FILE_FUNCTION",null);
  xmlTlAddTag(Tl,"REGISTERED_NAME","User1");
  xmlTlAddTag(Tl,"REGISTERED_PASSWORD","");
  xmlTlAddTag(Tl,"MESSAGE_HANDLE",MessageHandle);
  xmlTlAddTag(Tl,"CURRENT_FILESPEC",MessageFileToGet);

  var responseXML = xmlTlSend(Tl,Domain,Server,Protocol,ProxyURL);
  
  if (xmlTlGetTag(responseXML,"STATUS_NUM") == 0)
    {
    return(Base64Decode(xmlTlGetTag(responseXML,"CONTENT_DATA")));
    }
    
  return("");
  }
See Also:
xmlTlNew, xmlTlSend, Base64Decode