Commands for XML Creation, Manipulation and Validation
If you are not familiar with XML, it stands for eXtensible Markup Language much like HTML, to store and transport data and be self-descriptive.
In Worksoft SaaS the commands related to XML can be used in the context of the following common use cases:
- You want to read the data from a Web Service (that returns an XML document) and use the data as part of the automated tests running in Worksoft SaaS.
- You want your automated test running in Worksoft SaaS to read some values from the User Interface of your AUT and/or Data Files within Worksoft SaaS and feed such data into a Web Service (that accepts XML document as input) that does some processing that is a precursor for any additional automated tests to be executed in Worksoft SaaS.
Command | Purpose |
---|---|
xmlAddCDATA | This command is used to add CDATA within an XML document at the given path. |
xmlAppendToNodeList | This command is used to append values to the end of the indicated NodeList within an XML document. If the given path is not a valid in an XML document, the command fails with error "PATH _DOES_NOT_EXIST". |
xmlAssertPathExists | This command is used to check if the given path exists in the input 'XML_STRING'. If the mentioned path does not exist the run returns the value as "0" or "1" if the path exists. |
xmlAssertValidityGetParserError | This command is used to check if the XML string is well formed. If the XML document supplied in the input is invalid, the command fails with error "INVALID_XML" or the relevant error message. If the XML document is valid the variable will return "1". |
xmlComment | This command is used to add a comment to an XML string in the given path. If the given path is not a valid in XML document, the command fails with error "PATH _DOES_NOT_EXIST". |
xmlCompare | This command is used to compare two XML strings. If the mentioned XML Strings do not match then the run returns the value as "0" if strings do not match or "1" if the strings match. |
xmlCreateDocumentFromDataFile | This command is used to convert a Data File into a XML Node structure. Converts a Data File into a XML node structure. The Keys will be set equal to Attributes of the Data Definition linked to the Data File. The Values will be set using data from the Data File. |
xmlCreateDocumentFromDataSet |
This command is used to convert a DataSet into an XML document. The Keys will be set equal to Attributes of the Data Definition mapped to the DataSet. The Values will be set using data from the DataSet. To create a DataSet, Array Creation & Manipulation commands has to be used before this command. |
xmlExtractValuesByPaths | This command is used to extract the values from the given path in a XML string. If the XML document supplied in input is invalid, command fails with error "INVALID_XML". If the path supplied in input is invalid, command fails with error "PATH _DOES_NOT_EXIST" |
xmlGetDepth | This command is used to get the depth of a XML string. If the XML document supplied in input is invalid, command fails with error "INVALID_XML". |
xmlGetLength | This command is used to get the length of a XML String. If the XML document supplied in input is invalid, command fails with error "INVALID_XML". Returns the length of XML document or if a path argument is given, the length of the value within the document identified by the path. Returns NULL if any argument is EMPTY or the path argument does not identify a value in the document. An error occurs if the xml_string argument is not valid xml document or the path argument is not a valid path expression or contains a * or ** wildcard. The length of a document is determined as follows: 1. The length of a scalar is 1. 2. The length of an nodelist is the number of elements. 3. The length does not count the length of nested nodes. |
xmlInsertIntoDocument | This command is used to insert data in the XML document. If the XML document supplied in input is invalid, command fails with error "INVALID_XML". If the path mentioned is not part of the XML document, command fails with error "PATH _DOES_NOT_EXIST" . The path/value pairs are evaluated left to right.The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. A path/value pair for an existing path in the document is ignored and does not overwrite the existing document value.A path/value pair for a non existing path in the document adds the value to the document if the path identifies one of these types of values: 1) A member not present in an existing object.the member is added to the object and associated with the new value. |
xmlNodeListByIndex | This command retrieves Node List from XML document using "index" as reference. If index mentioned is not part of the XML document, command fails with error "INDEX_DOES_NOT_EXISTS_IN_XML_STRING". |
xmlNodeListByPath | This command retrieves Node List from XML document using "path" as reference. If path mentioned is not part of the XML document, command fails with error "PATH _DOES_NOT_EXIST". |
xmlRemoveFromDocument | This command removes data from XML document using "path" as reference. Removes data from a xml document and returns the result.Returns NULL if any argument is EMPTY.An error occurs if the XML document argument is not valid or any path argument is not valid path expression or is $ or contains a * or ** wildcard. The path arguments are evaluating left to right.The document produced by evaluating one path becomes the new value against which the next path is evaluated. It is not an error if the element to be removed does not exist in the document; in that case, the path does not affect the document. |
xmlReplaceNodesByPaths | This command is used to replace Nodes of XML document using "path" as a reference. Replaces existing keys in a XML document and returns the result. Returns NULL if any argument is EMPTY. An error occurs if the XML_string argument is not a valid XML document or any path argument is not a valid path expression or contains a * or ** wildcard. The path/key pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. A path/key pair for an existing path in the document overwrites the existing document value with the new key. A path/key pair for a non existing path in the document is ignored and has no effect. |
xmlReplaceValuesByPaths | This command is used to replace values of XML document using "path" as a reference. Replaces existing values in a XML document and returns the result. Returns NULL if any argument is EMPTY. An error occurs if the XML_string argument is not valid or any path argument is not a valid path expression or contains a * or ** wildcard. The path/value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. A path/value pair for an existing path in the document overwrites the existing document value with the new value. A path/value pair for a non existing path in the document is ignored and has no effect. |
xmlSearchValueByOccurrence | This command looks for a specific value in the target XML string using "path"as a reference. Returns 0 or 1 to indicate whether a specific value is contained in a target 'xml_string', or, if a path argument is given, at a specific path within the target 'xml_string'. Returns NULL if any argument is NULL or the 'path' argument does not identify a section of the target 'xml_string'. An error occurs if either 'xml_string' argument is not valid or the 'path' argument is not a valid path expression or contains a * or ** wildcard. |
xmlSetNodeAttributes | This command sets the "attributename" and "attributevalue" in given nodes of an XML document. If the XML document supplied in input is invalid, command fails with error "INVALID_XML". If path mentioned is not part of the XML document, command fails with error "PATH _DOES_NOT_EXIST ". |