Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

xml Split lines

Posted on 2006-07-11
5
Medium Priority
?
256 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:kristian_gr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 9

Expert Comment

by:riaancornelius
ID: 17088243
which vesion of the jre will the app run on?
0
 
LVL 9

Accepted Solution

by:
riaancornelius earned 2000 total points
ID: 17088247
on 1.5 you can use String[] tmp = e.getTextContent().split("\n");
0
 
LVL 9

Expert Comment

by:riaancornelius
ID: 17088352
on previous versions you can use a StringTokenizer.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17088453
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++;
     }
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17088680
String[] tmp = e.getTextContent().split("\\s*");

may be better if tabs or other whitespace are involved too
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question