XMLItemColl Object
Description
An object representing a collection of XML items. This object can be accessed using one of the following methods or properties:
Properties
![]() | Returns the number of items in the XML items collection. |
![]() | Returns the item found in the specified position within the XML item collection. |
Count Property
Description
Returns the number of items in the XML items collection.
Syntax
XMLItemColl.Count
Return Value
Number
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
The following example uses the Count property to count and display the number of CDATASections in the XML document before and after adding a new CDATASection.
Set doc = XMLUtil.CreateXML()
doc.LoadFile "d:\example.xml"
Set dataSections = doc.CDataSections()
msg = "First I had " & dataSections.Count() & " CDataSections."
newSection = "These characters <> are only allowed in CDATASections"
doc.AddCDATASection newSection
msg = msg + "Now I have " & dataSections.Count() & " CDataSections."
msgbox msg
Item Property
Returns the item found in the specified position within the XML item collection.
Syntax
XMLItemColl.Item (Position)
Argument | Type | Description |
---|---|---|
Position | Variant | The position of the item in the collection. The name (with quotes) or numeric index (with or without quotes) can denote the position. The first item in a collection is numbered 1. |
Return Value
String
![Closed](../../Skins/Default/Stylesheets/Images/transparent.gif)
The following example uses the Item property to display the comments in the document one by one.
Set doc = XMLUtil.CreateXML()
doc.LoadFile "d:\example.xml"
msgbox "The document version of this XML file is " & doc.GetVersion()
Set comments = doc.Comments()
doc.AddComment "comment1"
doc.AddComment "comment2"
index = 1
while index <= comments.Count()
msgbox "Comment " & index & ": " + comments.Item(index)
index = index + 1
wend