I am trying to select a single node on a COPY of an element, but I am
getting NullPointerException
when I tried it. For example, I am getting the null pointer exception on
node2 below. Is this a bug,
or am I not using it properly? Right now, I am cloning the Document to get
past this problem, but
I think this is a very kludgy solution. Any suggestion is greatly welcome.

============================================================================
===================
String str =
"<wine><prices><list>13.99</list><discounted>11.00</discounted></prices></wi
ne>";
SAXReader reader = new SAXReader();
Document doc = reader.read(new StringReader(str));

Element element = doc.getRootElement();
Element node = (Element) element.selectSingleNode("//list");
System.out.println("node: "+node.asXML());

try {
        Element elem2 = element.createCopy();
        Element node2 = (Element) elem2.selectSingleNode("//list");
        System.out.println("node2: "+node2.asXML());
}
catch (Exception e) {e.printStackTrace();}

Document doc2 = doc.clone();
Element elem3 = doc2.getRootElement();
Element node3 = (Element) elem3.selectSingleNode("//list");
System.out.println("node3: "+node3.asXML());
============================================================================
===================

Leon





This message contains information which may be confidential and privileged.
Unless you are the addressee  (or authorized to receive for the addressee),
you may not use, copy or disclose to anyone the message or any information
contained in the message.  If you have received the message in error, please
advise the sender by reply e-mail, and delete or destroy the message. 

Thank you.


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to