1. Use indexOf() and substring() provided by the String class to quickly obtain specific content in a file
public static void main(String[] args) {// Test the location where a word appears String reqMessage = "<?xml version=/"1.0/" encoding=/"ISO-8859-1/"?>" + "<in>" + "<head>" + "<Version>1.0.1</Version>"+ "<InstId>10000000000000032</InstId>" + "<AnsTranCode>BJCEBQBIReq</AnsTranCode>" + "<TrmSeqNum>2012082008200931036344</TrmSeqNum>"+ "</head>" + "</in>";int indexbegin = reqMessage.indexOf("<TrmSeqNum>");int indexend = reqMessage.indexOf("</TrmSeqNum>");System.out.println("<TrmSeqNum>'s position ===" + indexbegin);System.out.println("</TrmSeqNum>'s position ===" + indexend);System.out.println(reqMessage.substring(indexbegin + 11, indexend)); // 11 is the length of the string <TrmSeqNum>}The above java implementation uses a simple method of reading the content of a tag in an XML file using the String class. This is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.