StringTokenizer

I have a class which reads through an xml string. But I am not able to tokenize the xml string properly. I am getting strange results. I am attaching the code for perusal.

import java.util.StringTokenizer;

public class Test {

public static String abc = "<accountNumber>001002003</accountNumber><accountName>Test Account</accountName><accountNumber>111222333</accountNumber><accountName>Test Account</accountName><accountNumber>101202303</accountNumber><accountName>Test Account</accountName><accountNumber>321123231</accountNumber><accountName>Test Account</accountName>";

public static void main(String[] args){

StringTokenizer st = new StringTokenizer(abc,"<accountNumber>");

while(st.hasMoreElements()){

String s = st.nextToken();

System.out.println("--"+s+"--");

}

}

}

The result I am getting is :

--001002003--

--/--

--T--

--s--

-- A--

--/--

--111222333--

--/--

--T--

--s--

-- A--

--/--

--101202303--

--/--

--T--

--s--

-- A--

--/--

--321123231--

--/--

--T--

--s--

-- A--

--/--

whereas I was expecting the code to tokenize the xml string using the delimiter <accountNumber>.

Pls advidse.

[1434 byte] By [Achayana] at [2007-11-27 6:19:48]
# 1
You know, it's a good idea to read the Stringtokenizer API before using it, instead of guessing how it works.Read it and you know why that fails - you can't split on a String.
CeciNEstPasUnProgrammeura at 2007-7-12 17:34:44 > top of Java-index,Java Essentials,New To Java...
# 2
The API has a constructor :StringTokenizer(String str, String delim)which takes a String as a delimiter.
Achayana at 2007-7-12 17:34:44 > top of Java-index,Java Essentials,New To Java...
# 3
> which takes a String as a delimiter.Wrong. Straight from the c'tor's documentation:The characters in the delim argument are the delimiters for separating tokens. Please, consider reading the docs before starting to waste someones time.
CeciNEstPasUnProgrammeura at 2007-7-12 17:34:44 > top of Java-index,Java Essentials,New To Java...
# 4

public StringTokenizer(String str, String delim) :

So you mean to say each character in 'delim' can be a delimiter ?

I mean its not searching for the entire expression in 'delim' ?

If it finds any character which's present in 'delim', it'll tokenize on that ?

For example if delim = "<abc>", is it not a must that tokenizing will happen ONLY when "<abc>" is found in the given string ?

In other words, if java sees "a" or "b" or "c" or"<" or ">" alone, will it tokenize ?

Achayana at 2007-7-12 17:34:44 > top of Java-index,Java Essentials,New To Java...