I have an XML file and I want to create a graph based on some entities, then store this graph in an image, JPG or PNG.
So is there a library in Java to do something like this? Or are there some tricks by parsing XML files?
Here an example
XML file:
<?xml version="1.0"?>
<process>
<p n="1">Tove</p>
<p n="2">Jani</p>
<p n="2">Bill</p>
<p n="4">John</p>
</process>
And the output will be like this:

You can extract the names using one of the myriad of Java XML libraries. Here’s an example using XPath from a Java DOM:
Note: it may be a typo, but your XML is not well formed – attribute values must be quoted. XML parsing will fail otherwise.
You can use the AWT API to draw whatever you want:
This code just draws the names with some boxes around them. I’m sure my offsets are all over the place, but you probably get the idea.
There is an imageio API that can save in a few popular data formats: