I want to access the inner tag of an XML. Here is an XML I want to get URL From the Image tag.
<item>
<title>`
</title>
<image>
<url> any url here </url>
</image>
<description>
</description>
<pubDate></pubDate>
</item>
here is the following code I am using please can you tell how to access url of image?
NodeList nl = doc.getElementsByTagName("item");
int length = nl.getLength();
for (int i = 0; i < length; i++) {
Node currentNode = nl.item(i);
RSSItem _item = new RSSItem();
NodeList nchild = currentNode.getChildNodes();
int clength = nchild.getLength();
// Get the required elements from each Item
for (int j = 0; j < clength; j = j + 1) {
Node thisNode = nchild.item(j);
String theString = null;
String nodeName = thisNode.getNodeName();
theString = nchild.item(j).getFirstChild().getNodeValue();
if (theString != null) {
if ("title".equals(nodeName)) {
// Node name is equals to 'title' so set the Node
// value to the Title in the RSSItem.
_item.setTitle(theString);
}
like I have set title I want to store the url in thestring and set image url. I need to retrieve this feed for my app that I am making.
Help would be appreciated. Thanks.
0 comments:
Post a Comment