How to parse an XML document
Responses received from many types of connector rules are typically in the form of an XML document. The contents of these documents can be parsed into Process Commander properties.
In this example, a connector which returns conversion rates for two currencies has been manually created. The returned content from this connecter is structured as follows:
<GetRatesResponse xmlns="http://websevriceshare.com/"> <GetRatesResult>
It is recommended to use the Parse rules created by an accelerator.
To parse an XML document with Parse XML rules:
- For each returned XML element, create a corresponding property. The structure of the properties should match the structure of the XML document. For example, using the XML snipped above, the properties should be created as follows:
- Create a new Parse XML rule by navigating to the Integration-Mapping category and selecting Parse XML. Complete the New Rule Dialog. Set the Root Name Element field to the name of the property under which the rest of the properties appear (GetRatesParametersResponse in this example).
- Open the Mapping tab of the Parse XML form. Set the context of the root element. Double-click on the root node to access the Mapping Properties panel.
Using the SmartPrompt, select the page containing the newly created properties (GetRatesParametersResult in this example). Click OK.
- Using the Add element icon, add elements to the rule form according to the structure of the XML document. For Page properties, select the property in the element's Context Page field. For standard properties, select the property in the element's Property field.
Note: To reorder elements added previously, select and drag the element. Drop it in the desired location in the tree.
- Test the Parse rule by clicking the Run button in the tool bar. In the Run Rule window, provide the XML source to be parsed and click the Execute button. The resulting properties will appear on the clipboard.