Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Response TypeXPath ExpressionExplanation
Stringn/aA String response should be referenced in the stream attribute expressions as in.value Note that in.value will contain the complete string data referenced above.
XML/root/main/h:title

Note that the namspace prefix used here 'h' must be configured in the HTTP XML Namspaces form

This XPath expression will bring back all elements matching the xpath expression including the parent/grandparents and all child elements/subelements. i.e

<root xmlns:h="http://www.w3.org/TR/html4/"> <main page="PF Main Page" > <h:title h:name="PF Title">PF Title Text <h:datarow> <h:data h:initials="AD">Ali Dawson</h:data> <h:data h:initials="GP">Gary Parden</h:data> </h:datarow> </h:title> </main> </root>

The following examples show how to reference the returned xpaths html/xml data structure in stream attribute expressions:-
  • Xpath element text value: in.value -> returns 'PF Title Text'
  • Xpath element attibutes: in.h$name -> returns 'PF Title'
  • Xpath parent attributes: in.^.page -> returns 'PF Main Page'
  • Xpath child attributes: listToString(in.h$datarow.h$data.h$initials) -> returns 'AD,GP'
  • Xpath child attribute text values: listToString(in.h$datarow.h$data.value) -> returns 'Ali Dawson,Gary Parden'

Note the use of a $ instead of our usual : namespace notation.

Note the use of a ^ to traverse to the immediate parent element.

Note the use of the listToString function to handle multiple matching child elements/attributes.

HTML/html/body/table

Note that namspaces are not supported in the Xpath expression for HTML response types

This XPath expression will bring back all elements matching the xpath expression including the parent/grandparents and all child elements/subelements. i.e

<html> <body nodename="Html Body"> <table> <tbody> <tr> <td initials="AD">Ali Dawson</td> <td initials="GP">Gary Parden</td> </tr> </tbody> </table> </body> </html>

The following examples show how to reference the returned xpaths html/xml data structure in stream attribute expressions:-
  • Xpath parent attributes: in.^.nodename -> returns 'Html Body'
  • Xpath child attributes: listToString(in.tbody.tr.td.initials) -> returns 'AD,GP'
  • Xpath child attribute text values: listToString(in.tbody.tr.td.value) -> returns 'Ali Dawson,Gary Parden'

Note the use of a ^ to traverse to the immediate parent element.

Note the use of the listToString function to handle multiple matching child elements/attributes.

Note the use of the optional html <tbody> tags. If these are not in your html data, then phixflow will insert them to conform with the HTML standards. Therefore when using absolute XPath expressions, note that the tbody tags need to be included even if they are not present in the incoming HTML data.
i.e /html/title/table/tr should be replaced with /html/title/table/tbody/tr. Alternativley you can use //tr
The same applies when referencing parent/child nodes within the stream attribute expressions.

...

Since this document uses a default namespace ("urn:xmlns:company-com:message"), to refer to any element in an XPath expression that does not explicitly use a namespace you must use the default namespace. So to extract all record elements, you must first define a namespace in the collector for the default namespace. Suppose that you do and give this the name def. Then the XPath (defined in the XPath field on the Response tab) to extract all record elements will be //def:record

...