Element parent = new Element("Test");
Element child = new Element("child");
parent.appendChild(child);
grandparent.appendChild(parent);
ProcessingInstruction p1 = new ProcessingInstruction("c1", "1");
ProcessingInstruction p2 = new ProcessingInstruction("c1", "2");
ProcessingInstruction p3 = new ProcessingInstruction("c1", "3");
ProcessingInstruction p4 = new ProcessingInstruction("c1", "4");
doc.insertChild(p1, 0);
grandparent.insertChild(p2, 0);
parent.insertChild(p3, 0);
child.insertChild(p4, 0);