Initializing help system before first use

getattr

Purpose
Get the value of an attribute.
Synopsis
function getattr(doc:xmldoc, n:integer, name:string):text
function getboolattr(doc:xmldoc, n:integer, name:string):boolean
function getintattr(doc:xmldoc, n:integer, name:string):integer
function getrealattr(doc:xmldoc, n:integer, name:string):real
function getstrattr(doc:xmldoc, n:integer, name:string):string
Arguments
doc 
Document to use
Node number (must be an element)
name 
Name of the attribute
Return value
The value of the attribute or an empty string, 0 or false depending on the expected type.
Example
The following code extract prints the contents of 'name' (leftbound in a 10 character space) and the attributes 'id' of all 'employee' nodes, and the 'id' of their parent node.
  declarations
    DB: xmldoc
    AllEmployees: list of integer
  end-declarations

  getnodes(DB, "personnelList/region/employee", AllEmployees)
  forall(p in AllEmployees)
    writeln(textfmt(getvalue(DB, getnode(DB, p, "name")), -10),
            "(ID: ", getattr(DB,p,"id"), ") ",
            "region: ", getattr(DB, getparent(DB, p), "id"))
 
Output produced by this code will look as follows:
Lisa      (ID: L234) region: EMEA
James     (ID: J876) region: APAC
Sarah     (ID: S678) region: AM 
Further information
1. Values of attributes are stored as text objects: the first version of the routine returns a reference to the object containing the attribute value. Modifying this text will also alter the attribute value. Using one of the alternative versions of this routine allows to avoid having to perform a type conversion. Note however that no validation is performed and a conversion error will result in a 0 for a number and false for a Boolean without raising any error.
2. A default value (empty string, 0 or false) is returned if the requested attribute is not defined. Use function testattr to check whether a given node has a particular attribute.
Related topics
Module

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.