O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing the Search

Now that we have a nice-looking results page, it would be handy to have some results to actually put on it. In Listing 7.13, we're performing the basic search against index.xml to locate our product_ids.

Listing 7.13. Performing the Search
0: import java.io.*;
1: import javax.servlet.*;
2: import javax.servlet.http.*;
3: import org.apache.xalan.xslt.*;
4: import org.w3c.dom.*;
5: import org.apache.xerces.dom.*;
6: import org.apache.xml.serialize.*;
7: import org.apache.xerces.parsers.*;
					8: import de.gmd.ipsi.xql.*;
...

34:      Node bodyText =
35:           page.createTextNode("Results for keyword: "+key);
42:      body.appendChild(bodyText);
43:      body.appendChild(page.createElement("p"));
					44:
					45:      DOMParser parser = new DOMParser();
					46: parser.parse("/files/index.xml"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required