CciElement* cpiParent( int* returnCode, const CciElement* targetElement);
함수가 정상적으로 실행되면, 요청된 구문 요소의 주소가 리턴됩니다. 상위 요소가 없으면, 0이 리턴됩니다. 오류가 발생하면, 0(CCI_NULL_ADDR)이 리턴되고 returnCode 매개변수는 오류의 이유를 표시합니다.
다음 예는 샘플 구문 분석기 파일 BipSampPluginParser.c에서 발췌한 것입니다(116 - 173행).
void* parseNextItem( CciParser* parser, CciContext* context, CciElement* element ){ void* endMarker; void* startMarker; PARSER_CONTEXT_ST* pc = (PARSER_CONTEXT_ST *)context; CciElement* returnElement = element; CciElement* newElement; size_t markedSize; const CciChar* data; int rc; if (pc->trace) /* Skip any white space */ skipWhiteSpace( (PARSER_CONTEXT_ST *)context ); /* Are we at the end of the buffer? */ if (pc->iIndex == pc->iSize) return(0); } /* Are we within a tag? */ if (pc->iInTag) { if (pc->iCurrentCharacter == chCloseAngle) { /* We have reached the end of a tag */ pc->iInTag = 0; advance( (PARSER_CONTEXT_ST *)context, parser ); } else if (pc->iCurrentCharacter == chForwardSlash) { /* We may have reached the end of an empty tag */ advance( (PARSER_CONTEXT_ST *)context, parser ); if (pc->iCurrentCharacter == chCloseAngle) { pc->iInTag = 0; advance( (PARSER_CONTEXT_ST *)context, parser ); cpiSetElementCompleteNext(&rc, element, 1); returnElement = cpiParent(&rc, element); }