Field-Map Scripting

4.1.11.2.10 HasAttribute

HasAttribute function


Prototype:

function HasAttribute(const AttributeName: string): boolean;

Description:

Use the HasAttribute function to check whether or not the given XML element contains an attribute specified by its name passed by the AttributeName parameter.

Syntax:

variable := TScriptXMLElement.HasAttribute(AttributeName);


Part

Description


variable

A variable declared as Boolean


TScriptXMLElement

A variable declared as an instance of the TScriptXMLElement class


AttributeName

A string parameter specifying the attribute of the given XML element

Return value:

True if there is an attribute of the specified name, otherwise false


Example:


var

  ElementList: TScriptXMLElementList;

  Element: TScriptXMLElement;

  i: integer;

  AttributeName, LayerName: string;


begin

// open XML document and assign Element


  ElementList := Element.GetChildElements('');


for i := 0 to ElementList.GetCount - 1 do

begin

       with ElementList.GetElement(i) do

begin

       if HasAttribute('LAYER') then

        LayerName := GetStringAttributeAsString('LAYER');

       if HasAttribute('ATTRIBUTE') then

        AttributeName := GetStringAttributeAsString('ATTRIBUTE');

end;

end;

end.




See also:

GetRootElement; GetElementName; GetChildElements; GetFirstChildElement; GetElementText; GetElementInteger; GetElementDouble; GetElementBoolean; GetElementCDATA; HasAttribute; HasNoNullAttribute; GetStringAttribute; GetStringAttributeAsString; GetStringAttributeAsDateTime; GetIntegerAttribute; GetIntegerAttributeAsInteger; GetFloatAttribute; GetFloatAttributeAsVariant; GetFloatAttributeAsFloat; GetBooleanAttribute; GetFirstChildElementStringAttribute; GetFirstChildElementStringAttributeAsString; GetFirstChildElementIntegerAttribute; GetFirstChildElementIntegerAttributeAsInteger; GetFirstChildElementFloatAttribute; GetFirstChildElementFloatAttributeAsVariant; GetFirstChildElementFloatAttributeAsFloat; GetFirstChildElementBooleanAttribute; Name; FreeXMLElement; SaveValuesToTable; GetRootElementName; GetFirstChildElementText; GetFirstChildElementinteger; GetFirstChildElementDouble; GetFirstChildElementboolean