I have a code snippet i've been working on but not getting very far.
What I have is a text file which looks like an XML but i want to get the data between the tags and ignore the tags themselves. I want to count the number of data items between the tags and create a 2D array so if for example I have this:
<tag1>
Data 1
Data 2
Data 3
Data 4
</tag1>
<tag2>
test1
test2
test3
</tag2>
I would like to create an array 4 by 3.
I think i can get the first array right but when i try and get the other bit it gives the wrong answer
int d1=0, d2=1;
while (! filename.eof()) //Loop through lines
{
getline(filename, line);
string test = "<";
if(line.find("<",0) == string::npos)
cout << line << endl;
unsigned int pos1 = line.find(sub1, 0);
unsigned int pos2 = line.find(sub2, 0);
if( pos1 = string::npos)
if(pos2 != string::npos)
d1++;
if( pos1 = string::npos)
if(pos2 = string::npos)
d2++;
}
IntArrayPtr *m = new IntArrayPtr[d1];
int i;
for(i=0; i < d1; i++)
m[i] = new int[d2];
cout << d1 << endl;
cout << d2 << endl;
filename.close();