<%@ page import = "org.w3c.dom.*,org.apache.xerces.parsers.DOMParser,org.xml.sax.*" %> Address Book CONTENT OF THIS PART¦¦TABLE FORM¦¦HOMEPAGE¦¦ WORKPAGE¦¦ TECFA

Address Book of Contacts

Here are some of the contacts which I treasure much (not exactly of course).


<% // URL String URL = "http://tecfa.unige.ch/staf/staf-e/sun/staf2x/xml/try.xml"; // Entry element (fiche) String ROOT_ELEMENT_TAG = "Entry"; // DONNEES // charge le document et cree le document xml ou exit si cela ne marche pas // Note: Il est OBLIGATOIRE d'implementer ce try (avec xml.jar de Sun en tout cas!) try { DOMParser parser = new DOMParser(); parser.parse(URL); Document TheDocument = parser.getDocument(); // Say Hello out.println("

Contacts structured by " + ROOT_ELEMENT_TAG+" :

"); // List of entries (fiches) NodeList entries = TheDocument.getDocumentElement().getElementsByTagName(ROOT_ELEMENT_TAG); int nEntries = entries.getLength(); // Deal Entry by Entry for(int i=0; i < nEntries; i++) { Element currentEntry = (Element) entries.item(i); NodeList entryItems = currentEntry.getChildNodes(); int nEntryItems = entryItems.getLength(); out.println(""); } out.println("
SUN April 2000"); } catch (SAXParseException e) { out.println("The File is not well formed."); out.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber()); } catch (SAXException e) { out.println("SAX exception found"); out.println(e.getMessage()); // e.printStackTrace(out); } catch (Exception e) { out.println (e.getMessage()); // e.printStackTrace(out); out.println ("

On arrete tout de suite, reparez l'erreur SVP


"); return; } %> Source