-
-
Save todvora/490895c9e596e51f88d1 to your computer and use it in GitHub Desktop.
JSOUP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; | |
public class Main { | |
public static final String INPUT = "<Snapshot id=\"142102345\">" + | |
"<Stats name=\"runtime\" statType=\"moduleRuntime\" il=\"-2\">" + | |
"<CS id=\"2\" sT=\"1422004481541\" lST=\"1427376591432\" ct=\"225331\"></CS>" + | |
"<CS id=\"3\" sT=\"1422004481541\" lST=\"1427376591432\" ct=\"503459\"></CS>" + | |
"<CS id=\"5\" sT=\"1422004481541\" lST=\"1427376591432\" ct=\"0\"></CS>" + | |
"</Stats>" + | |
"</Snapshot>"; | |
public static void main(String[] args) { | |
Document doc = Jsoup.parse(INPUT); | |
final Elements elements = doc.select("CS"); // CSS selector | |
for(Element e : elements) { | |
System.out.println(e.attr("id") + ":" + e.attr("ct")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment