[jdom-interest] "Cloning" Problem
Jason Hunter
jhunter at acm.org
Thu Nov 16 17:17:08 PST 2000
The new clone is detached from its parent and stands alone, thus
getParent() returns null. I just modified the clone() Javadocs to make
this clearer.
-jh-
> Wang K H wrote:
>
> Hi,
>
> I just started using JDOM and I am facing a problem with the clone()
> method of Element.
>
> My code is as follows :
>
> Element tempNode = (Element)currentNode.clone();
> System.out.println("Parent " +
> currentNode.getParent().getName());
> while(tempNode.getParent() != null)
> {
> currentNodeHName = tempNode.getName() + "/" +
> currentNodeHName;
> tempNode = tempNode.getParent();
> System.out.println("Path " + currentNodeHName);
> }
> The first print statement shows the name of the parent. The second
> print statement did not even get printed. This means that after the
> cloning, the parent is lost, that's why the while loop is not entered.
> Is this a known problem or there is something wrong with my code.
>
> Thanks a lot for any help.
>
More information about the jdom-interest
mailing list