hey guys, i need help with the following: i have a string like this: <logout reason="user logged out" time="12:32 2006"> and i want to split this string (using split("\\s")), but i want it to give me tokens like this:
reason "user logged out" time 12:32 2006
if i use split("\\s\"") it only gives me 1 token: reason="user logged out" time="12:32 2006"
which is basically back to square one! PLEASE HELP thx in advance
To elaborate a little bit, I believe Paul is suggesting that if the String represents valid XML (which would necessarily include an end tag), then it would be easiest to use some sort fo XML parser. If it's not valid XML, then I guess you can use regular expressions, but the split() method probably won't help much as the delimiters are too different. I'd recommend using a Pattern and Matcher to find the whole tag, and then another Pattern and Matcher to locate the individual attributes within the tag. This will require some knowledge of regular expressions however. And there are some complications which may not be immediately obvious. If you can use a standard XML parser, that will probably be simpler.