LabWindows/CVI

CVIXMLFindElements

CVIXMLStatus CVIXMLFindElements (CVIXMLElement parentElement, char *tag, ListType *elementList);

Purpose

Finds all elements with the given tag that are descendants of the element passed in the parentElement parameter.

Parameters

Input
Name Type Description
parentElement CVIXMLElement The element handle must be a valid CVIXMLElement.
tag char * Tag of the elements to search for. If you pass NULL for this parameter, an error is returned.

Certain tags are invalid XML. These include those with white space, non-alphanumeric characters, or numbers.

The special string "*" matches all descendant elements, but other regular expressions and wild cards are not supported.
Output
Name Type Description
elementList ListType On output, contains the list of matching elements. The ListType data type resides in the Programmer's Toolbox. You can find more information about the ListType data type in toolbox.fp. After you finish using this list, you should discard each element in the list and dispose the list.

/* Example code - error checking omitted */


ListType elementList = 0;

CVIXMLElement element = 0;

int i, numElements;


CVIXMLFindElements (parent, "search_tag", &elementList);


/* Traversing the list */

numElements = ListNumItems (elementList);

for (i = 0; i < numElements; ++i)

{

/* Get the ith element */

ListGetItem (elementList, &element, i+1);


/* Do something with the element... */

}


/* Other code... */


/* When done, discard the elements and dispose the list */

for (i = 0; i < numElements; ++i)

{

/* Remove each element and discard it */

ListRemoveItem (elementList, &element, FRONT_OF_LIST);

CVIXMLDiscardElement (element);

}

ListDispose (elementList);

Return Value

Name Type Description
status CVIXMLStatus Indicates whether the function was successful.

A zero indicates success.

You can call CVIXMLGetErrorString to obtain textual descriptions of error codes. Among the more commonly encountered errors are:
E_OUTOFMEMORY Out of memory.
E_INVALIDARG Invalid argument to a function.

Additional Information

Library: CVIXML

Include file: toolbox\cvixml.h

LabWindows/CVI compatibility: LabWindows/CVI 7.0 and later