0

I am reading XML documents from a stream into a string. However, there is the possibility of multiple XML documents (identically structured) within the same string. I read several questions on stackoverflow and other sites which provided examples of splitting using XPath and some other methods. In my case will it be fine for me to simply use Java's String.spit() method?

All I require is for a string with two or more identically structured XML documents be split into separate strings. I'm asking because I have not seen anyone else made mention of this, so in the event that I am missing the obvious reason for this please point it out. Thank you.

Each document is structured as follows:

<?xml version = "1.0" encoding = "UTF-8"?>
<telemetry>
........
</telemetry>

1 Answer 1

1

If you know that each document starts with <?xml version = "1.0" encoding = "UTF-8"?>, you can use that as a delimiter (since it cannot legally be part of the document). You can also consume the delimiter if that makes splitting the string easier; absence of the xml declarattion will not affect the parsing, since it is the default.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, just what I needed to hear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.