YedXml - Navigate_And_Run

NAME:
Navigate_And_Run

SYNOPSIS:
SINT Navigate_And_Run(void *pvO,SINT (*pFunc)(XML_ELEMENT *));

DESCRIPTION:
The method recursively navigates XML internal tree of the object instance pvO, and executes the user function pointed to pFunc with any XML element in the tree.
pFunc must point to a function having this interface:

SINT name_of_function(XML_ELEMENT *);

This function will receive a pointer to an XML element which content can be modified, because the pointer points to the real XML element, not to a copy of it.

Navigation of XML tree will terminate when the last XML element has been reached, or when the user function returns a value other than 0.

Format of XML_ELEMENT structure has shown in details in Get_XML_Declaration manual page.

A small example:

int Foo(XML_ELEMENT *pElem)
{
printf("Navigating XML element [%s]\n",pElem->scbElement);
if(!(strcmp(pElem->scbElement,"stop"))) return -1; // if you want to stop when XML tag is <stop>
return 0;
}
// ....
YedXml *p=New(YedXml);
SINT siStatus;
XML_ELEMENT pFind;
// ....
p->Get_XML_Buffer(p,"./foo.xml");
siStatus=p->Load_Tree(p);
// ....
siStatus=p->Navigate_And_Run(p,Foo);
printf("Navigate_And_Run returns [%d]\n",i);
// ....

RETURN VALUE:
The method returns value returned from the last invocation of pFunc user function.


http://yed.sourceforge.net