メインコンテンツまでスキップ
バージョン: 20 R9

DOM Count XML attributes

DOM Count XML attributes ( elementRef ) : Integer

引数説明
elementRefTextXML要素参照
戻り値Integer属性数

説明

DOM Count XML attributes コマンドは、elementRefで指定したXML要素中に現れるXML属性数を返します。XML属性に関する詳細はの節を参照してください。

例題

要素の属性値を配列に受け取る前に、XML要素の属性数を取得します:

 var myBlobVar : Blob
var $xml_Parent_Ref;$xml_Child_Ref : Text
var myResult : Text
var $numAttributes : Integer

$xml_Parent_Ref:=DOM Parse XML variable(myBlobVar)
$xml_Child_Ref:=DOM Get first child XML element($xml_Parent_Ref)

$numAttributes:=DOM Count XML attributes($xml_Child_Ref)
ARRAY TEXT(tAttrib;$numAttributes)
ARRAY TEXT(tValAttrib;$numAttributes)
For($i;1;$numAttributes)
DOM GET XML ATTRIBUTE BY INDEX($xml_Child_Ref;$i;tAttrib{$i};tValAttrib{$i})
End for

上の例題で、$numAttributesは3になり、*tAttrib{1}*は"Font"、*tAttrib{2}*は"N"、tAttrib{3}は"size"、そしてtValAttribは"Verdana","1","10"になります。

注: 配列のインデックス番号はXMLファイル中に表示される属性の順番通りではありません。XML中、属性のインデックスはnameのアルファベット順に並びかえられた属性の位置を示します。

システム変数およびセット

コマンドが正しく実行されるとシステム変数OKに1が設定され、エラーが発生すると0が設定されます。

参照

DOM Count XML elements

プロパティ

コマンド番号727
スレッドセーフである
システム変数を更新するOK

AltStyle によって変換されたページ (->オリジナル) /