# “~>” Notation

The second non-standard syntax is to provide a convenient way to extract values from multiple elements in the XML. In the following example, we are attempting to index the entry and want to extract the full name of every contact:

    <root>
      <entry>
        <contact>
          <firstname>Fred</firstname>
          <lastname>Bloggs</lastname>
        </contact>
        <contact>
          <firstname>John</firstname>
          <lastname>Smith</lastname>
        </contact>
      </entry>
    </root>

Our implementation allows the following XPath expression to concatenate values from multiple elements:

        "concat(~/contact/firstname, ' ', ~/contact/lastname)"

Unfortunately, this actually concatenates the first values from each inner expression and returns only the string

        “Fred Bloggs”

The following expression allows all of the full names to be returned (this can be used when constructing metadata, or can be used with the `xml:XPathValues` function with Lua):

        "~/contact ~> concat(~/firstname, ' ', ~/lastname)"

When used with the `xml:XPathValues` function in Lua, as below,

        xml:XPathValues("~/contact ~> concat(~/firstname, ' ', ~/lastname)")

this returns the following Lua value:

        { "Fred Bloggs", "John Smith" }

The new syntax added here is the operator “~>”.

        "LeftXPath ~> RightXPath"

The value on the left of the "~>" is parsed as an XPath expression, and should return a set of elements.

The value on the right of the "~>" is parsed as an XPath expression, and is processed relative to all the elements returned by the left side.

For more information on the normal XPath syntax supported see http://en.wikipedia.org/wiki/XPath_1.0.

© Copyright 2019 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm