Hey you can use Xpath inside the document to fetch the node like this
document.selectSingleNode("/catelog/entity");
Then get the attribute of it and you can either remove the node and add the fresh node with new attribute id.
I would recommend to use the XSLT to manage this if the XML transformations is very frequent
thanks
goldhouse