I have an XML file as per below, and I need to generate a .txt file with the plain text in the tag, each one in a row, using Java.
I read that I could use SAX in order to access the different labels, but in this case, where there can be random tags inside the like in the example below, this is not valid.
What is the best approach to do this? Regex perhaps?
<?xml version="1.0" encoding="utf-8"?>
[...]
<source>
<g id="_0">
<g id="_1">First valid sentence</g>
</g>
</source>
<source>Another valid string</source>
The output results.txt should be something like this:
First valid sentence
Another valid string