Java Reference
In-Depth Information
Then iterate over all of the top-level document elements of the RSS data.
Element e = d.getDocumentElement();
NodeList nl = e.getChildNodes();
for (int i = 0; i < nl.getLength(); i++)
{
Node node = nl.item(i);
String nodename = node.getNodeName();
Once we find the <channel> element, the loadChannel method is called to load
the channel data.
// RSS 2.0
if (nodename.equalsIgnoreCase("channel"))
{
loadChannel(node);
}
If this is an RSS 1.0 feed, then there will be <item> elements at the top level. If any item
tags are encountered, then we call loadItem to process them.
// RSS 1.0
else if (nodename.equalsIgnoreCase("item"))
{
loadItem(node);
}
This process continues until all top level elements have been processed.
Loading the Channel
The loadChannel method is called to load a <channel> element. This method
begins by looping across all of the child elements of the <channel> element.
NodeList nl = channel.getChildNodes();
for (int i = 0; i < nl.getLength(); i++)
{
Once a child node is located, examine the name of that node.
Node node = nl.item(i);
String nodename = node.getNodeName();
If this is an <item> element, then call loadItem to load that item.
if (nodename.equalsIgnoreCase("item"))
{
loadItem(node);
}
Search WWH ::




Custom Search