getValueByPath
The getValueByPath method gets the value of a sub-field, specified by path. If you pass this method the path of a sub-field that has multiple values, only the first value is returned. To return all of the values from a multi-value sub-field, see getValuesByPath.
Syntax
getValueByPath( path )
Arguments
| Argument | Description |
|---|---|
path
|
(string) The path of the sub-field. |
Returns
(String). A string containing the value.
Example
Consider the following document:
<DOCUMENT>
...
<A_FIELD>
<subfield>
<anothersubfield>the value to return</anothersubfield>
</subfield>
</A_FIELD>
...
</DOCUMENT>
The following example demonstrates how to retrieve the value "the value to return" from the sub-field anothersubfield, using a LuaField object representing A_FIELD:
local field = document:getField("A_FIELD")
local value = field:getValueByPath("subfield/anothersubfield")