I have a file that can be read as a text box, I would like to get only the data available after
start="n= and end="n=
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 1.0//EN" "SMIL10.dtd">
<head>
</head>
<body>
<audio start="n=10.815s" end="n=19.914s"/>
</body>
</xml>
I tried doing the following :
String startTime = readString.replaceAll(".*start=\"n=|\\s.*", "").trim();
String endTime = readString.replaceAll(".*end=\"n=|\\s.*", "").trim();
Log.e("Start Time is :" , startTime);
Log.e("endTime Time is :" , endTime);
Its working fine, with just getting the start time and end time but it also shows the <?xml tag.
How do I fix this?
I would rather use an XML parser to read this. Regexps aren't suited to parsing XML/HTML etc. You'll find numerous references in SO relating to this.
For Java, DOM and SAX are possibilities, but JDOM might make an easier starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With