Hi Soumanjoy
You found another bug in the DOM implementation! :-)
I've patched it and added your code as a test case. The latest daily build
should work now.
BTW be careful in your code to ensure that there's only one root element in
a document. From the looks of this code, you're going to try add multiple
elements to the document, which is an error - they need to be children of
the root element.
> DOMDocument oDocument = new DOMDocument("Root");
> //Add two node elements with attributes "name" and "id"
> Element oParent = oDocument.createElement("Parent"); //<--This now
works
> fine (used to throw an error earlier)
> oParent.setAttribute("name", "N01");
> oParent.setAttribute("id", "ID01");
>
> oDocument.appendChild(oParent); //<-- Fails here, Error message is
below
First parent. All other elements should be children of this one.
> oParent = oDocument.createElement("Parent");
> oParent.setAttribute("name", "N02");
> oParent.setAttribute("id", "ID02");
> oDocument.appendChild(oParent);
> oParent = oDocument.createElement("Parent");
> Element oSearch = (Element)oDocument.selectSingleNode("//Parent[@name
=
> 'N01']");
> System.out.println(oSearch.getAttribute("id"));
James
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user