CMarkup GetNthAttrib Method

bool CMarkup::GetNthAttrib( int n, MCD_STR& strName, MCD_STR& strValue ) const;

Call GetNthAttrib to get the string name and value of the Nth attribute in the main position element. The first attribute is 0, the second is 1, etc. If there is no current position or the current position node does not have the specified attribute, it returns false.

Similar to GetAttribName, this method lets you iterate through the attributes of an element or processing instruction. However, this is usually better because it provides the attribute value without an additional call to GetAttrib, and it returns a bool which is convenient for looping. For example:

MCD_STR strName, strAttrib;
int n = 0;
while ( xml.GetNthAttrib(n++, strName, strAttrib) )
  // do something with strName, strAttrib

GetNthAttrib also works when the main position is a processing instruction node with attributes. See Node Methods in CMarkup.