Link to home
Start Free TrialLog in
Avatar of kristian_gr
kristian_grFlag for Norway

asked on

xml Split lines

Hi.
I have a xml tag like this:
<ot>54231
76541
89621</ot>
I can read this tag in to org.w3c.dom.Element e, and then convert it to a String using e.getTextContent().

But I can't figure out how to split this textContent into String[];
I use both windows and Solaris, so I need something that works on both platforms.
Avatar of riaancornelius
riaancornelius

which vesion of the jre will the app run on?
ASKER CERTIFIED SOLUTION
Avatar of riaancornelius
riaancornelius

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
on previous versions you can use a StringTokenizer.
Avatar of girionis
You could also try

StringTokenizer st = new StringTokenizer(e.getTextContent());
String [] tokens = new String[st.countTokens()];
int counter = 0;
     while (st.hasMoreTokens()) {
         tokens[counter] = st.nextToken();
         counter++;
     }
String[] tmp = e.getTextContent().split("\\s*");

may be better if tabs or other whitespace are involved too