tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henrique, Manuel" <>
Subject Digester / vector usage
Date Mon, 02 May 2005 15:12:48 GMT
Hello all,

It made now 2 weeks that I have a little issue with the XML parsing. I use
examples founds in the net. My question is very simple, if I have for
example an XML file like that:

<catalog library="somewhere">

      <author>Author 1</author>
      <title>Title 1</title>

      <author>Author 2</author>
      <title>His One Book</title>

      <name>Mag Title 1</name>

      <article page="5">
         <headline>Some Headline</headline>

      <article page="9">
         <headline>Another Headline</headline>

      <author>Author 2</author>
      <title>His Other Book</title>

      <name>Mag Title 2</name>

      <article page="17">
         <headline>Second Headline</headline>


I have the catalog.class:
package com.erdv.logicacmg.control;

import java.util.Vector;

public class Catalog {
   private Vector books;
   private Vector magazines;

   //constructeur de catalog
   public Catalog() {
      books = new Vector();
      magazines = new Vector();
	//gestion des livres
   public void addBook(Book newBook) {
   public void setBooks(Vector books){
	   this.books = books;
   public Vector getBooks(){
	   return books;
   //gestion des magazines
   public void addMagazine(Magazine newMagazine) {
   public void setMagazines(Vector magazines){
	   this.magazines = magazines;
   public Vector getMagazines(){
	   return magazines;


book class:
package com.erdv.logicacmg.control;

public class Book {
   private String author;
   private String title;

   public Book() {}

   public void setAuthor(String newAuthor) {author = newAuthor;}
   public void setTitle(String newTitle) {title  = newTitle;}
   public String getAuthor(){
	   return author;
   public string getTitle(){
	   return title;
the magazine class:
package com.erdv.logicacmg.control;

import java.util.Vector;

public class Magazine {
   private String name;
   private Vector articles;

   public Magazine() {
      articles = new Vector();

   public void setName(String newName) {name = newName;}
   public String getName(){
	   return name;

   public void addArticle(Article a) {
   public void setArticles(Vector articles){
	   this.articles = articles;
   public Vector getArticles(){
	   return articles;


and so on...

I have also a digester class that create the rules and parse the file as I
want. All is ok into the log file. It indicates no issue.

Now what I what is to get my values from my java code. I dont know how to
do. I search help with the vector usage but nothing helps me to get my

For example: in a java code how can I get the Headline value for the
magazine called "Mag 1" for the article page "5".

I tried in my java code to create a c as new catalog and after? How can I
do. In all examples they uses Vectors but nobody explains how to do after.

What it seems is that everybody talks about parsing, about digester but
nobody gives how to get the wanted value from the XML. Each time I ask to
someone always the same answers "digest.parse()", "now catch your object and
it's finished". Yes, it's exactly what I want but how can I do??

Could somebody help me please?



PS: I know I am a newbee in Tomcat/Java so no need to mock at me.

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It
may contain proprietary material, confidential information and/or be subject to legal privilege.
It should not be copied, disclosed to, retained or used by, any other party. If you are not
an intended recipient then please promptly delete this e-mail and any attachment and all copies
and inform the sender. Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message