Here's what I ended up doing. It fixed the code. No more codes. I was getting P0327 and sometimes P0328. The Xterra is currently in "Not Ready" mode, but that is okay because before the fix, I would clear the codes and it would come back almost immediately. After the fix, I cleared the codes once, and it has not come back.
I ordered this part from Amazon:
http://amzn.to/1WHnbPc It has the knock sensor and the pig tail. I found the wire, spliced it and just used butt connectors, then taped it all up. It was pretty easy.
I also went and bought a longer bolt from Lowes while I was there, along with a matching lock washer. It was a 10mm head, M6-1.00 30mm long. The one I remove is only 10mm long.
Here is the new knock sensor relocated.


I also replaced some of the plastic looms and did some retaping around the engine as most were falling apart.

I was sweating this but it was totally easy. Took about 30 minutes which includes me taping up stuff.