ValueDefault (XmlDoc/XmlNode function)

From m204wiki
Revision as of 00:13, 7 December 2010 by 198.242.244.47 (talk) (Created page with "<span style="font-size:120%; color:black"><b>String-value of selected node (allow empty XPath result)</b></span> ValueDefault function [[Category:XmlN...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

String-value of selected node (allow empty XPath result)

ValueDefault is a member of the XmlDoc and XmlNode classes.

The ValueDefault function obtains a substring of the string-value of a node, including its Text descendants. ValueDefault provides an optional argument to use as a return value if the XPath expression that designates the node to process is empty.

Syntax

  %str = nr:ValueDefault([Xpath], [default])

Syntax Terms

%str
A Unicode string variable for the returned substring or for the default value. Prior to Sirius Mods version 7.6, this is an EBCDIC string.
nr
An XmlDoc or XmlNode, used as the context node for the XPath expression. If an XmlDoc, the Root node is the context node.
XPath
A Unicode string that is an XPath expression that results in a nodelist. The head of the nodelist is the node to process. This is an optional argument whose default is a period (.), that is, the node referenced by the method object (nr). Prior to Sirius Mods version 7.6, this argument is an EBCDIC string.
default
A Unicode string expression to use as the result of ValueDefault if the result of XPath is the empty nodelist. An optional argument, its default is the null string. Prior to Sirius Mods version 7.6, this argument is an EBCDIC string.

Usage Notes

  • As of Sirius Mods version 7.3, the ValueDefault string arguments and result may include only non-null EBCDIC characters that translate to Unicode. As of Sirius Mods version 7.6, these strings are Unicode or are converted to Unicode. For more information about the effects of this version 7.6 change, see Strings and Unicode.

Example

The following example displays the default string, a single underscore ( _ ) character:

    Begin
    %d Object XmlDoc
    %d = New
    %d:LoadXml('<t>Test</t>')
    Print %d:ValueDefault('/x', '_')
    End

Request-Cancellation Errors

  • XPath is invalid.
  • Insufficient free space exists in CCATEMP.


See Also

  • Value discusses the string-value of various node types.
  • For more information about using XPath expressions, see XPath.