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