#include
#include
#include
#include
#include
#include
using namespace std;
FILE *fp; int no_of_nodes=0, string_ctr=0, vect_ctr=0, vect_ctr1=0,pos_ctr=0,*pos;
struct MyNode
{
string name; vector children;
}*myroot, *myroot1, **tree_pattern, **subtree_pattern;
//FUNCTION PROTOTYPES DECLARATION ... static void print_element_names(xmlNode *); static MyNode* preprocess(xmlNode *,MyNode *, int); int printMyNode(MyNode *); void print(MyNode **, int); void print_pos_array(int *,int); int check_child(MyNode *, MyNode *);
int main() { xmlDoc *doc = NULL; xmlDoc *doc1 = NULL; xmlNode *root_element = NULL; xmlNode *root_element1 = NULL; const char *pattern = "/home/naveen/Desktop/SubTrees_in_Tree/Programs/pattern.xml"; const char *subpattern = "/home/naveen/Desktop/SubTrees_in_Tree/Programs/subpattern.xml";
doc = xmlReadFile(pattern, NULL, 0); doc1 = xmlReadFile(subpattern, NULL, 0);
if (doc == NULL || doc1 == NULL) printf("error: could not parse file %s or %s.\n", pattern,subpattern); else { fp = fopen("input_file.txt","w");
// For Getting The Root Element Node ... root_element = xmlDocGetRootElement(doc); print_element_names(root_element); printf("The Total Number Of Nodes In The Tree : %d \n",no_of_nodes); fprintf(fp,"\n");
tree_pattern = (struct MyNode **)malloc(no_of_nodes*sizeof(struct MyNode *)); pos = (int *)malloc(no_of_nodes*sizeof(int));
no_of_nodes = 0; root_element1 = xmlDocGetRootElement(doc1); print_element_names(root_element1); printf("The Total Number Of Nodes In The SubTree : %d\n",no_of_nodes);
int n = no_of_nodes; subtree_pattern = (struct