Listing 1
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:journal="
title="Oracle Magazine" publisher="Oracle Publishing">
<journal:journal journal:date="November-December 2008">
<journal:article journal:section="ORACLE DEVELOPER">
<title>Instant ODP.NET Deployment</title>
<author>Mark A. Williams</author>
</journal:article>
<journal:article journal:section="COMMENT">
<title>Application Server Convergence</title>
<author>David Baum</author>
</journal:article>
</journal:journal>
<journal date="March-April 2008">
<article section="TECHNOLOGY">
<title>Oracle Database 11g Redux</title>
<author>Tom Kyte</author>
</article>
<article section="ORACLE DEVELOPER">
<title>Declarative Data Filtering</title>
<author>Steve Muench</author>
</article>
</journal>
</catalog
Listing 2
XMLNodetitleNode=(XMLNode)document.selectSingleNode
("/catalog/journal/article[@section=' ORACLE DEVELOPER']/title");
String title=titleNode.getFirstChild().getNodeValue();
System.out.println("Title of first Article in ORACLE DEVELOPER
Section (with nodes not in any namespace) is "+ title);
XMLNode authorNode=(XMLNode)document.selectSingleNode("/catalog/
journal/article[title= Oracle Database 11g Redux']/author");
String author=authorNode.getFirstChild().getNodeValue();
System.out.println("Author of Title Oracle Database 11g Redux
is "+ author);
XMLNode sectionNode=(XMLNode)document.selectSingleNode
("/catalog/journal[@date=March-April 2008']/article[2]
/@section");
String section=sectionNode.getNodeValue();
System.out. println("Section of 2nd Article in Journal of date
March-April 2008 is "+ section);
Listing 3
NodeList nodeList = document.selectNodes("/catalog/journal[@date=
'March-April 2008']/article/title");
System.out.println("Article Titles published in journal of March-
April 2008 are: ");
for(int i=0; i<nodeList.getLength(); i++){
titleNode=(XMLElement)nodeList.item(i);
title=titleNode.getFirstChild().getNodeValue();
System.out.println(title);
}
nodeList=document.selectNodes("/catalog/journal[@date='March-April
2008']/article/@section");
System.out.println("Articles in journal of March-April 2008 were
published in Sections: ");
for(int i=0; i<nodeList.getLength(); i++){
sectionNode=(XMLNode)nodeList.item(i);
section=sectionNode.getNodeValue();
System.out.println(section+" ");
}
Listing 4
nodeList=document.selectNodes("/catalog/journal:journal[@journal:
date= 'November-December 2008']/journal:article/title",
resolver );
for(int i=0; i<nodeList.getLength(); i++){
titleNode=(XMLElement)nodeList.item(i);
title=titleNode.getFirstChild ().getNodeValue();
System.out.println(title);
}
}catch(IOException e){
System.err.println("IOException"+e.getMessage());
}
catch(XMLDOMException e){
System.err.println("XMLDOMException"+e.getMessage());
}
catch(XMLParseException e)
{System.err.println("XMLParseException"+e.getMessage());
}
catch(XSLException e){
System.err.println("XSLException"+e.getMessage());
}
catch(SAXException e){
System.err.println("SAXException"+e.getMessage());
}
}