S
stevengarcia
I have multiple root XML documents in a String that looks like
"<?xml...><response .../><?xml...><response .../><?xml...><response
..../>"
There are three valid XML documents above, unfortunately I have all of
them in one String so (as far as I can tell) XML parsing with dom4j
will not give me three Document objects.
I am trying to write a method that will split the above String into
three separate strings that are all valid XML, and can be parsed by an
XML parser. First I tried String.split()...but there is no good
delimiter. Then I tried writing a regular expression, and I think
regex's will work here, but I'm not proficient at this advanced topic.
The other thing too is the real XML has carriage feeds and other random
characters between each XML document. The XML within each document is
assured to be valid, however.
Is a regex a good way to do this? Your help would be appreciated.
"<?xml...><response .../><?xml...><response .../><?xml...><response
..../>"
There are three valid XML documents above, unfortunately I have all of
them in one String so (as far as I can tell) XML parsing with dom4j
will not give me three Document objects.
I am trying to write a method that will split the above String into
three separate strings that are all valid XML, and can be parsed by an
XML parser. First I tried String.split()...but there is no good
delimiter. Then I tried writing a regular expression, and I think
regex's will work here, but I'm not proficient at this advanced topic.
The other thing too is the real XML has carriage feeds and other random
characters between each XML document. The XML within each document is
assured to be valid, however.
Is a regex a good way to do this? Your help would be appreciated.