Java: Count a special letter or number from a .XML -


I want to ask if possible, for example I calculate a particular letter or number:

"A:"

from an .xml file? And write it as a variable?

For example:

foo.xml:

  & lt; Question & gt; & Lt; Question & gt; & Lt; Variant & gt; A: variant 1 & lt; / Variant & gt; & Lt; Variant & gt; B: variant 2 & lt; / Variant & gt; & Lt; / Question & gt; & Lt; Question & gt; & Lt; Variant & gt; A: variant 1 & lt; / Variant & gt; & Lt; Variant & gt; B: variant 2 & lt; / Variant & gt; & Lt; / Question & gt; & Lt; Question & gt; & Lt; Variant & gt; A: variant 1 & lt; / Variant & gt; & Lt; Variant & gt; B: variant 2 & lt; / Variant & gt; & Lt; / Question & gt; & Lt; / Question & gt;  

int counter = 3

Because I have three "A:"

I want to use variables for a solution sentence.

syso ("you have" + points + "+" + counter + "number");

Thank you for your help!

Null; while ((sCurrentLine = br.readline ()) = faucet {sb.append (sCurrentLine);} Pattern Pattern = Pattern.compile ("A:"); Matcher matcher = pattern.matcher (SB); Int count = 0; while (matcher.find ()) {count ++;} System.out.println (calculation);

xml f The code is also included to read the string as a string, matcher.find () only finds the next example of the match, so that you have to dodge through the whole thing, annoyingly


Comments