Read XML
This activity retrieves values from an XML document. There are a variety of ways to define the XML document.
How does this activity look in the Designer Pane?
- Drag it from the Toolbox Pane and drop it in the Designer Pane.
To configure this activity
Select the activity in the Designer Pane to configure the following property boxes in the Properties Pane.
See the following options:
-
Activity Name
Once added to a workflow definition, the default name of an activity can be changed. Providing a custom name for an activity helps you remember the role it plays.
To name an activity
- Add an activity to your workflow by dragging it from the Toolbox Pane and dropping it in the Designer Pane.
- Select the activity in the Designer Pane.
- Under Activity Name in the Properties Pane, replace the default name.
Note: Activity names cannot be the same as any other activity name in the workflow, they cannot be the same as the workflow's name, they must be less than 100 characters, they must contain at least one alphanumeric character, they cannot be "Name," and they cannot be the same as the activity's runtime type (which is usually only an issue with custom activities).
-
Activity Description
Use the Activity Description to provide descriptive text to help you remember the role that the activity plays in the workflow. All activities contain a default description that you can modify while constructing your workflow.
To modify an activity description
- Add an activity to your workflow by dragging it from the Toolbox Pane and dropping it in the Designer Pane.
- Select the activity in the Designer Pane.
- Under Activity Description in the Properties Pane, replace the default description.
-
XML Source
Use this property box to specify the XML document you want to process.
- Add the Read XML activity to your workflow definition by dragging it from the Toolbox Pane and dropping it in the Designer Pane.
- In the XML Source property box, specify the XML document you want to process. If the XML document is retrieved as part of a previous activity in the workflow, specify the desired token.
-
XPath Expression Tokens
Use this property box to configure the activity. Specify the XML document you want to traverse and an XPath expression for how to traverse the XML document.
To configure XML information
- Add the Read XML activity to your workflow definition by dragging it from the Toolbox Pane and dropping it in the Designer Pane.
- In the Properties property box, click New Token.
- Specify a token name.
- In XPath Expression, manually specify an appropriate XPath expression to traverse the XML document and select values or click to help you build an XPath expression.
- Choose one of the following options:
- Create a token: Choose between choosing to create a new token
- Update token: or to store the result in an existing token.
- In the If multiple matches are found drop-down option, choose what happens when the specified XPath expression matches multiple nodes in the XML document.
Note: Click the Click here to test the pattern link, to display the Test Input text box. Paste or type a sample XML document to see the result of your XPath expression.
-
Advanced Properties
Click the Advanced button at the top of the Properties Pane to:
- Automatically remove default namespace declarations
- Define prefix-namespace mappings that will be in the XML source document
Clearing out default namespaces or defining the prefixed namespaces that will be available in the XML source document allow you to more easily construct XPath expressions without having to use wildcards to match any namespaces.
Example: A XML source document contains this namespace declaration: <xmlns:LF="http://laserfiche.com/namespaces/importengine">. After defining this LF prefix http://laserfiche.com/namespaces/importengine namespace pairing in a Read XML activity's advanced options, you can write an XPath Expression that uses the LF prefix like so: //LF:ElementName//@AttributeName.
- Click the area under XML Namespaces to display the XML Namespace Options dialog box.
- In the left column, specify the prefix associated with the namespace. In the right column specify the namespace associated with the prefix.
Tip: Use the Autodetect namespaces link to specify a sample XML document that has the desired namespace declarations to automatically define the available mappings.
- Select the Automatically clear default namespaces option to also clear out default namespace declarations in the XML source document.
Example: The response from an HTTP Web Request activity is an XML document that contains an element or attribute with a Laserfiche document ID. A Read XML activity can retrieve this document ID for use in a later step in the workflow.
Important: The Read XML activity supports XPath 1.0.
Well, before anything, the usecase depends on the source of the Xml string itself... there are many ways for the user to get an Xml string that they might want to parse. For example, the string can come from these places:
HTTP Web Request Activity, as part of the response (which will be in html) - this is the most likely case, by far, I'd think
A LF Document which contains something in Xml - not sure how likely this case might be, but i can imagine some forms might be in xml format
A user can read a file from disk that's in xml and use the activity to parse that file - this case is not very likely because WF is not great with file systems yet
User will use a Write Xml activity to create xml... after manipulating the xml, they can read it thru Read Xml - We are forgoing the Write Xml activity for 9.1 but it will be around later... at this point, they can, as you mentioned, use Create Token Activity to create Xml (although it's a very bad UI for that)
A side case, but I imagine power users may end up using Xml to store data instead of having multiple tokens, since they can use Read Xml to parse thru that with some ease - this is a "power use" case and not sure if it'll happen but it's worth considering
there are probably other sources where the user can probably get Xml strings they might want to read. The case that I see as the most meaningful, at the moment, is to get useful information out of the new Http activities, since the response is in xml form
another usecase is that, whether through Scripts, Custom Activities or Http activity, users integrating with 3rd party APIs will very often get responses in html. If they wrote custom activites and scripts, chances are they manage these responses thru their respective scripts, but having the ReadXml activity is very useful for them because they can just output the response as a string and parse it through the activity, making it easier to interact with the 3rd party API (for example, they dont need to recompile the Custom Activity every time they want to parse some new kind of response)