getnodes
getnodes |
Purpose
Synopsis
procedure getnodes(doc:xmldoc, n:integer, p:string|text, l:list of integer)
procedure getnodes(doc:xmldoc, p:string, l:list of integer)
procedure getnodes(doc:xmldoc, n:integer, l:list of integer)
Arguments
|
doc
|
Document to use
|
|
n
|
Base node number (
0 when not provided)
|
|
p
|
Path to the node (
"*" when not provided)
|
|
l
|
List where result is returned
|
Example
Here are a number of examples how to retrieve nodes with specific properties:
declarations
DB: xmldoc
Employees, AllEmployees: list of integer
end-declarations
! Get all employees in the Americas
getnodes(DB, "personnelList/region[@id='AM']/employee", Employees)
! All employees who started before 2005
getnodes(DB, "personnelList/region/employee/startDate[number()<2005]/..",
Employees)
! All employees whose names start with "J"
getnodes(DB, "personnelList/region/employee", AllEmployees)
forall(n in AllEmployees) do
getnodes(DB, n, "./name[starts-with(string(),'J')]/..", Employees)
forall(p in Employees) save(DB, p, "")
end-do
! Employees speaking at least 3 languages (=have a third "language" entry)
getnodes(DB, "personnelList/region/employee/language[position()=3]/..",
Employees)
Further information
1. Refer to section
Paths in a document for a detailed description of the syntax and semantic of XML paths.
2. This function resets the list it receives as parameter: the provided list is returned empty if no node can be found.
Related topics
Module
