Answer the question
In order to leave comments, you need to log in
How to select 2 values at once by tag name in one loop?
Hello.
There is this xml
<s:Body>
<GetQualityFulfilmentResponse xmlns="http://schemas.septembers.ru/septic/workflow/quality/services">
<GetQualityFulfilmentResult xmlns:a="http://schemas.dataseptic.org/2004/07/Septic.Quality" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Segments xmlns:b="http://schemas.septembers.ru/septic/flow/quality/types">
<b:QualityRuleFulfilmentSegment>
<b:AcceptedMessagesCount>0</b:AcceptedMessagesCount>
<b:FailedCount>
1
</b:FailedCount>
<b:SentMessagesCount>0</b:SentMessagesCount>
<b:SucceededCount>
123
</b:SucceededCount>
<b:TimeFrom>2017-07-27T16:32:40.737+03:00</b:TimeFrom>
<b:TimeTo>2017-07-27T18:12:40.737+03:00</b:TimeTo>
</b:QualityRuleFulfilmentSegment>
</a:Segments>
</GetQualityFulfilmentResult>
</GetQualityFulfilmentResponse>
</s:Body>
org.jsoup.nodes.Document doc = Jsoup.parse(xml, "", Parser.xmlParser());
for (org.jsoup.nodes.Element e : doc.getElementsByTag("b:FailedCount")) {
System.out.println(e.ownText());
}
for (org.jsoup.nodes.Element e : doc.getElementsByTag("b:SucceededCount")) {
System.out.println(e.ownText());
}
Answer the question
In order to leave comments, you need to log in
Elements result = doc.getElementsByTag("b:FailedCount");
result.addAll(doc.getElementsByTag("b:SucceededCount"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question