I've been renaming xml nodes using the document.renameNode() method:
Document document = loadXml(xml);
NodeList list = document.getElementsByTagName("Entry1");
for (int i=0; i < list.getLength();)
{
document.renameNode(list.item(i), "", "Entry");
}
However, the Java version I'm deploying to (1.5.0_09-b03) doesn't support the renameNode method. Any ideas how I could write the above in a way that's compatible with this v开发者_如何学JAVAersion of Java?
Thanks in advance.
Hmm... the Java 1.5 API doc says renameNode() is supported. Are you sure you don't have access to that method? Are you using org.w3c.dom classes?
As mentioned in my comment I was able to do a replaceAll on the string replacing "Entry1" with "Entry" and then loading that as xml.
Thanks.
精彩评论