Question: I am new to iphone development.I want insert my xml parsed contents into a sqlite3 database and retrieve it and display it in a tableView.I am able to parse and directly display the contents using nsxml parser.Please help me how to proceed to store the contents in a database and retrieve it .Thanks.

Answer: 
THIS SOLUTION IS WRITTEN IN C++ BUT THE PRINCIPLE IS THE SAME

If your puzzle is represented by

```
char puzzle[N][N]

```

declare the arrays

```
int xd[8] = { -1, -1,  0, +1, +1, +1,  0, -1 };
int yd[8] = {  0, -1, -1, -1,  0, +1, +1, +1 };

```

and then when you want to check if word 'w' can be found at location (x, y) in direction d (d between 0 and 7 inclusive), just do

```
bool wordsearch(const char *w, int x, int y, int d) {
  if (*w == 0) return true; // end of word
  if (x<0||y<0||x>=N||y>=N) return false; // out of bounds
  if (puzzle[y][x] != w[0]) return false; // wrong character
  // otherwise scan forwards
  return wordsearch(w + 1, x + xd[d], y + yd[d], d); 
}

```

And then the drivers

```
bool wordsearch(const char *w, int x, int y) {
  int d;
  for (d=0;d<8;d++)
    if (wordsearch(w, x, y, d)) return true;
  return false;
}

bool wordsearch(const char *w) {
  int x, y;
  for (x=0;x<N;x++) for(y=0;y<N;y++) if (wordsearch(w, x, y)) return true;
  return false;
}

```
Do NOT use a 2 dimensional array for the puzzle. For an NxM word search, use an array of (N+2)\*(M+2). Put padding of 1 character all the way around your puzzle. So the example becomes:

```

......
.BXXD.
.AXEX.
.TRXX.
.FXXX.
......

```

Where the periods are the padding and all of this is really a 1d array.

Calling the width of the new grid the row span (S), you can now create an array of 8 direction "vectors" D=[ -S-1, -S, -S+1, -1, 1, S-1, S, S+1 ]. Using this, you can look from any position in the grid Puzzle[position] to its neighbor in any direction by using Puzzle[position+D[direction]].

Your position of course is now a single variable instead of a pair of coordinates. The padding around the border tells you if you've reached the edge of the board and should be a character that is never used in the interior of the puzzle.