You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by toby cabot <to...@caboteria.org> on 2004/08/24 17:42:34 UTC

Re: [ot] JAXP Problems

On Tue, Aug 24, 2004 at 08:38:16AM -0400, John Woolsey wrote:
> Okay I am having trouble with JAXP. I parse through the tree and find my 
> element_nodes easily. Then I go for getNodeValue and it always seems to 
> be null. I am using Xerces 2 to process. Any ideas what I am doing wrong?
> 
snip...
>        Node child = childList.item(i);
>        if( child.getNodeType() == Node.ELEMENT_NODE){
>          Element element = (Element)child;
>          String name = element.getTagName();
>          NamedNodeMap namedNodeMap = element.getAttributes();
>          System.out.println( name + "  " + 
> namedNodeMap.item(0).getNodeValue() );
>          result.put( name, child.getNodeValue() );

I'm not a JAXP expert, but I play one on mailing lists.  I checked the
javadoc of the Node class and it looks as if it's behaving as
documented: the nodeValue of an element node is null.

http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html

see the table in the introduction.

HTH,
Toby

Re: [ot] JAXP Problems

Posted by John Woolsey <jw...@activation.net>.
After much futzing around I realized that the data is a child node and 
then things got better. Thanx for the help.

                                                                         
            - bfn - JAW

toby cabot wrote:

>On Tue, Aug 24, 2004 at 08:38:16AM -0400, John Woolsey wrote:
>  
>
>>Okay I am having trouble with JAXP. I parse through the tree and find my 
>>element_nodes easily. Then I go for getNodeValue and it always seems to 
>>be null. I am using Xerces 2 to process. Any ideas what I am doing wrong?
>>
>>    
>>
>snip...
>  
>
>>       Node child = childList.item(i);
>>       if( child.getNodeType() == Node.ELEMENT_NODE){
>>         Element element = (Element)child;
>>         String name = element.getTagName();
>>         NamedNodeMap namedNodeMap = element.getAttributes();
>>         System.out.println( name + "  " + 
>>namedNodeMap.item(0).getNodeValue() );
>>         result.put( name, child.getNodeValue() );
>>    
>>
>
>I'm not a JAXP expert, but I play one on mailing lists.  I checked the
>javadoc of the Node class and it looks as if it's behaving as
>documented: the nodeValue of an element node is null.
>
>http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html
>
>see the table in the introduction.
>
>HTH,
>Toby
>
>
>  
>