I am having string like
String str="<?xml version="1.0" encoding="UTF-8"?><head><heading>Appliance Repairs</heading></head><?xml version="1.0" encoding="UTF-8"?>Appliance Repairs<?xml version="1.0" encoding="UTF-8"?>Air conditioning and refrigeration services<?xml version="1.0" encoding="UTF-8"?>Accountants<?xml version="1.0" encoding="UTF-8"?>Accident Management"
Here I have to extract only the string which was present outside of the tag.
output I required here is given below::
Appliance Repairs
Appliance Repairs
Air conditioning and refrigeration services
Accident Management
And I have to store these value into List, help me for this .. thanks in advance
Use
SAXParser. Inherit your handler fromDefaultHandlder, and overridecharactersto concatenate string parts coming from the parser (you can useStringBuilderfor that).Clear the builder in
startElement; add the finished string to your list inendElement.Here is a link to a quick tutorial on parsing XML in Java using SAX parser.