InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IIDXMLDOMNList Class Referenceabstract

#include <IIDXMLDOMNList.h>

Public Member Functions

 IIDXMLDOMNList (const BIB_NAMESPACE::CAXENListDOM &)
 
virtual int32 Length () const =0
 
virtual IIDXMLDOMNodeGetNthNode (int32 which)=0
 

Detailed Description

The IIDXMLDOMNList (DOM NodeList) object provides the abstraction of an ordered collection of nodes.

The items in the node list are accessible via an index, starting from 0.

Node lists are "live", in that any changes to the document tree are immediately reflected in any IIDXMLDOMNLists that may have been created for that tree.

WARNING: Because node lists are "live", the following is a very common error that should be avoided:


// Move children from this node to another

IIDXMLDOMNList *nl = parent.getChildNodes();

unsigned int length = nl.getLength();

IIDXMLDOMNList *kid;

for (unsigned int i = 0; i < length; ++i) {

    kid = nl.item(i);

    if (kid)

        parent->RemoveChild(kid); //This changes length of nl!

}

The index 'i' will exceed the modified length of the list, which will result in 'kid' being invalid.

Invalid Parameters

Unless otherwise indicated, it is an error to use an invalid container (IsValid() == false), or a NULL pointer, as a parameter to any function. In some instances, the requirement that a specific parameter must be valid is repeated in the commentary for the specific function. The lack of any indication in the commentary for the specific function should still be taken to mean that an invalid container or NULL pointer will result in an error.

Member Function Documentation

virtual IIDXMLDOMNode* IIDXMLDOMNList::GetNthNode (int32 which)
pure virtual

Get a node by index

If 'which' is greater than or equal to the number of nodes in the list, returns nil.

Parameters
whichIndex into the list, starting with 0.
Returns
Returns the specified node. If node cannot be found because 'which' < 0 or >= Length nil will be returned.
virtual int32 IIDXMLDOMNList::Length () const
pure virtual

Get number of nodes in list

The range of valid child node indices is 0 to length-1 inclusive.

Returns
Number of nodes