Thanx both of you it seems to work, but how do I set nodeValue then?

/ Jess

---
Jess Nielsen
Management Consultant / System Developer

Ementor Denmark A/S
E-mail: [EMAIL PROTECTED]
Phone: (+45) 24 69 35 81
               (+45) 70 10 08 44

WTF? :o)




Ian Roberts <[EMAIL PROTECTED]>
27-07-01 12:08
Please respond to xerces-j-dev

 
        To:     [EMAIL PROTECTED]
        cc: 
        Subject:        Re: more node value problems


On Sun, 27 May 2001 [EMAIL PROTECTED] wrote:

> Hi there,
> 
> I'm having a problem with the .getNodeValue() too.
> 

<snip />

> 
System.out.println(indst.getChildNodes().item(0).getNodeName().toString()); 

> //Output = "Service"
>       String service = 
> indst.getChildNodes().item(0).getNodeValue().toString(); //Output = 
> NullPointerException
>       System.out.println("The value of the element node service " + 
> service); // Never reached
> 
> The Node is an ElementNode.
> 
>       XML file:
>         <?xml version="1.0" encoding="UTF-8"?>
>         <Indstillinger>
>                 <Service>aService</Service>
>         </Indstillinger>

The text content of Element nodes is not stored as the node value of the
Element node, it is stored as Text node children of the Element.  Calling
getNodeValue() on an Element node will always return null.  In your
example, the text "aService" is found in

indst.getChildNodes().item(0).getFirstChild()

which is an instance of org.w3c.dom.Text

Ian

-- 
Ian Roberts, Software Engineer        DecisionSoft Ltd.
Telephone: +44-1865-203192            http://www.decisionsoft.com





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to