Here you can find the source of extractClasses(String xmlContent)
public static Collection<String> extractClasses(String xmlContent)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class Main { public static Collection<String> extractClasses(String xmlContent) { final Set<String> classList = new LinkedHashSet<String>(); try {/*from ww w .java 2 s.com*/ SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); DefaultHandler handler = new DefaultHandler() { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { if (attributes.getQName(i).equals("class")) { classList.add(attributes.getValue(i)); } } } } }; byte[] bytes = xmlContent.getBytes("UTF8"); InputStream inputStream = new ByteArrayInputStream(bytes); InputSource source = new InputSource(inputStream); saxParser.parse(source, handler); } catch (Exception e) { e.printStackTrace(); } return classList; } }