How to get the data from the P2

Dear all,
I use the P2 and P1 to compare with analytical solution by paraview.
The error of P2 is bigger than P1.
I know that the warning " Finite element variables saved using paraview must be in P0 or P1 ".
Why not use paraview to load P2?
Is it because paraview can only read the vertices, the other three nodes on the border can’t?

And, how to get the data from P2?


Paraview only knows Cell type (P0) and Data type (P1), you can not read P2 finite element function directly with paraview.
You can export P2 data in a file using something like this:

for (int i=0; i<Uh.ndof; ++i)
  file >> u[][i] << endl;

Dear simon.garnotel,
If I want to get values on a line that I select (like paraview), how can I do?
example:a square (0,0), (2,0), (2,2), (0,2)
How to get values on a line (point(0,1) to point(2,1))?