int config(){
char tempFCDAldInst[64] = {0};
domTree = xmlParseFile(“9_2Sample.ICD”);
printf(“enter the domtree\n”);
root = xmlDocGetRootElement(domTree);
if (root == NULL)
return -1;
// MACconfigNode = FindFirstChild(root, “MACconfig”, “”);
//
// if (MACconfigNode == NULL)
// return -2;
IEDNode = FindFirstChild(root, “IED”, “”);
if (IEDNode == NULL)
return -2;
AccessPointNode = FindFirstChild(IEDNode, “AccessPoint”, “”);
if (AccessPointNode == NULL)
return -3;
ServerNode = FindFirstChild(AccessPointNode, “Server”, “”);
if (ServerNode == NULL)
return -4;
LDeviceNode = FindFirstChild(ServerNode, “LDevice”, “”);
if (LDeviceNode == NULL)
return -5;
LN0Node = FindFirstChild(LDeviceNode, “LN0”, “”);
if (LN0Node == NULL)
return -6;
DataSetNode = FindFirstChild(LN0Node, “DataSet”, “”);
if (DataSetNode == NULL)
return -7;
FCDANode = FindFirstChild(DataSetNode, “FCDA”, “”);
if (FCDANode == NULL)
return -8;
// memset(tempFCDAldInst, 0, 64);
while(FCDANode != NULL){
printf(“entering the while loop\n”);
// strcpy(s_enable, (char *) xmlGetProp(seriesNode,
// (const xmlChar *) “enable”));
strcpy(tempFCDAldInst, (const char *)xmlGetProp(FCDANode,
(const xmlChar *)“ldInst”));
printf(“ldInst = %s\n”, tempFCDAldInst);
FCDANode = FCDANode->next;
}
return 0;
}
int main(int argc, char *argv[]){
int config_num = 0;
config_num = config ();
printf(“config_num is %d\n”, config_num);
return EXIT_SUCCESS;
}
运行结果是
entering the while loop
ldInst = 1
entering the while loop
memory fault(core dumped)