The sort of thing we normally suggest is like this
Your code waits for the '<' character then starts accumulating characters until it sees the '>' character. Then it parses the data.
This provides a couple of mechanisms that make the code more robust.
Note that this only works if < and > will never appear in your data. If they might then use different characters that don't. This also means that this technique cannot be used for binary data.
Rob