Shouldn't something like this work?
Assuming a document formatted as such:
<root>
<element id = "a"></element>
</root>
Node node = doc.query("/root/element").get(0);
String id = node.getDocument().getRootElement().getAttribute("id");
When I print the value of the root element, it looks as if this should work. What's failing, here?