Query XML Action

Execute a XPath Expression on a XML-String

1.Add “Query XML” Action to a SharePoint Designer 2010 Workflow

image

2. Configure the action

image

XML: The XML String to query

XPath: The XPath expression

Selection Type: Defines what should be selected (Inner XML, Outer XML, Value)

Output: The result of the XPath Query. When the expression returns more than one node each node will be append to the result string. E.g. “<Node>1</Node><Node>2</Node><Node>3</Node>”. This would not be valid XML and could not processed with the Query XML Action. To generate valid XML again surround the nodes with a root node with the Build Dynamic String Action.

Example 1: Simple XML without Namespaces

image

XML

image

XPath

image 

Example 1: Atom XML with Namespaces

Do a Twitter Search. Select all tweet titles and write them to history log:

image

Click the URL to see how the XML-Result from the HTTP-Request looks like http://search.twitter.com/search.atom?q=sharepoint.

To select the title of the tweets we use the following XPath Expression:

image

When the XML contains namespaces use “local-name” in XPath Expression!

 

3. Publish and run the workflow

Last edited Jan 6, 2011 at 2:35 PM by cglessner, version 3

Comments

No comments yet.