Title: question about : xpathselector.selectSingleNode(doc)
You should check the element thats returned form selectSingleNode() - maybe it cannot be found and you're getting a NullPointerException.
 
Without a sample program and XML document its hard to know what the problem is....

James
----- Original Message -----
Sent: Tuesday, June 18, 2002 3:48 PM
Subject: [dom4j-user] question about : xpathselector.selectSingleNode(doc)

Hi,

I am new with dom4j...
All works well but I have a question about this point :
I select an Element from its xpath address :
The two parts of code are working :

Element richText_Element =
        (Element) xpoix_Element.selectSingleNode("richDesc[@type='product']/richText");
richText_Element = richText_Element.addText(rt + ", station : " + nb);

or :

DocumentFactory I_DocumentFactory = new DocumentFactory();
XPath xpath = I_DocumentFactory.createXPath("richDesc[@type='product']/richText");
Element richText_Element = (Element) xpath.selectSingleNode(xpoix_Element);
richText_Element = richText_Element.addText(rt + ", station : " + nb);

But when the element "richDesc[@type='product']/richText" is not present in the document,
the program crashes without Exception...

Is it normal or Is sth missing in my code ?

Thank you for your help,
Regards.

François Paulus.

Reply via email to