Java: problems while parsing a XML file
<p>I have the following XML and I'm trying to print the value of some nodes. For example, with the following code I want to print the </p>

<pre><code> NodeList list = doc.getElementsByTagName("photo");
 element = (Element)list.item(0);
 list = element.getChildNodes();
 System.out.println(list.item(0).getNodeName());
 System.out.println(list.item(0).getNodeValue());
</code></pre>

<p>and I get</p>

<pre><code>null
#text
</code></pre>

<p>instead of "title" and "bigfish live 200812"</p>

<p>What am I doing wrong ?
thanks</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
&lt;rsp stat="ok"&gt; 
&lt;photo id="2882550369" secret="21054282c8" server="3106" farm="4" dateuploaded="1222202793" isfavorite="0" license="0" safety_level="0" rotation="0" views="5" media="photo"&gt; 
    &lt;owner nsid="64878451@N00" username="fishthemusic" realname="masayoshi yamamiya" location="kawasaki, japan" iconserver="4" iconfarm="1" /&gt; 
    &lt;title&gt;bigfish live 200812&lt;/title&gt; 
    &lt;description&gt;photo by Kazuhiro Nakamura&lt;/description&gt; 
    &lt;visibility ispublic="1" isfriend="0" isfamily="0" /&gt; 
    &lt;dates posted="1222202793" taken="2008-09-24 05:46:33" takengranularity="0" lastupdate="1222998937" /&gt; 
    &lt;editability cancomment="1" canaddmeta="0" /&gt; 
    &lt;publiceditability cancomment="1" canaddmeta="0" /&gt; 
    &lt;usage candownload="1" canblog="1" canprint="0" canshare="1" /&gt; 
    &lt;comments&gt;0&lt;/comments&gt; 
    &lt;notes /&gt; 
    &lt;tags&gt; 
        &lt;tag id="314160-2882550369-80673" author="64878451@N00" raw="bigfish" machine_tag="0"&gt;bigfish&lt;/tag&gt; 
        &lt;tag id="314160-2882550369-5558" author="64878451@N00" raw="live" machine_tag="0"&gt;live&lt;/tag&gt; 
        &lt;tag id="314160-2882550369-29726586" author="64878451@N00" raw="upcoming:event=1167424" machine_tag="1"&gt;upcoming:event=1167424&lt;/tag&gt; 
    &lt;/tags&gt; 
    &lt;urls&gt; 
        &lt;url type="photopage"&gt;http://www.flickr.com/photos/fishthemusic/2882550369/&lt;/url&gt; 
    &lt;/urls&gt; 
&lt;/photo&gt; 
&lt;/rsp&gt;
</code></pre>
