DOM Find XML element

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2004


DOM Find XML element (elementRef; xPath) elementRef

ParameterTypeDescription
elementRefStringXML element reference
xPathText | BLOBXPath path of the element to look for
Function resultelementRefReference of the element found (if applicable)

Description

The DOM Find XML element command allows you to look for a specific XML element in an XML structure. The search starts at the element designated by the elementRef parameter.

The XML node to seek is set expressed in XPath notation using the xPath parameter (see the "Use of XPath notation" parameter in the Presentation of XML Commands section). Indexed elements can be used.

Note: In conformity with the XML standard, searches will be case sensitive.

The command returns the XML reference of the element found.

Example

This example lets you quickly look for an XML element and display its value:

   vFound:=DOM Find XML element(vElemRef;"Items/Book[15]/Title")
   DOM GET XML ELEMENT VALUE(vFound;value)
   ALERT("The value of the element is: \""+value+"\"")

The same search can also be done as follows:

   vFound:=DOM Find XML element(vElemRef;"Items/Book[15]")
   vFound:=DOM Find XML element(vFound;"Book/Title")
   DOM GET XML ELEMENT VALUE(vFound;value)
   ALERT("The value of the element is: \""+value+"\"")

Note: As you can see in the above example, the XPath path must always begin with the name of the current element. This detail is important when you are handling relative XPath paths.

See Also

DOM Count XML elements, DOM Create XML element.

System Variables or Sets

If the command has been executed correctly, the system variable OK is set to 1. Otherwise, it is set to 0 and an error is generated.

Error Handling

An error is generated when:

The element reference is invalid

The specified xPath path is invalid.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next