[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[xml] Problems when making two consecutives "queries" using XPath



Hi There,

	I'm parsing a XmlDocument that has a inline Schema.

	In order to get the types of the variables that exist in "data
sector" I go trough the schema checking the names of the variables and then
using xPath I will the value of that variable.

	I'm getting problems if I try to make two "queries" using xPath (in
the example I use the same query):

	code snippet
			xmlXPathObjectPtr xDataResult;
			xmlNodePtr dataNode;

			xmlXPathObjectPtr xDataResult1;
			xmlNodePtr dataNode1;

			char* value;

//Query 1
			xDataResult =
xmlXPathEvalExpression(*xPathData,context);
			dataNode = xDataResult->nodesetval->nodeTab[0];
			value = xmlNodeListGetString(doc,
dataNode->xmlChildrenNode, 1);
			printf(">>>>>>> '%s' name:%s value:%s type:%s
(simpleField) <<<<<<<\n",*xPathDoc, dataNode->name,
value,xmlGetProp(node,"type"));
			xmlFreeNode(dataNode);
			xmlXPathFreeObject(xDataResult);

//Query 2 
			xDataResult1 =
xmlXPathEvalExpression(*xPathData,context);
			dataNode1 = xDataResult->nodesetval->nodeTab[0];
			value = xmlNodeListGetString(doc,
dataNode->xmlChildrenNode, 1);
			printf(">>>>>>> '%s' name:%s value:%s type:%s
(simpleField) <<<<<<<\n",*xPathDoc, dataNode->name,
value,xmlGetProp(node,"type"));
			xmlFreeNode(dataNode);
			xmlXPathFreeObject(xDataResult);


	do I need to do something between the 2 queries ? If I recreate the
doc and the context this will work, but there must be a better way.


Thank you in advance,

Luís Pinho



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]