xpath tester

Run Settings
LanguageJava
Language Version
Run Command
import static java.lang.System.out; import javax.xml.parsers.*; import javax.xml.xpath.*; import java.io.ByteArrayInputStream; import static java.nio.charset.StandardCharsets.UTF_8; class Main { public static void main(String[] args) throws Throwable { String bsMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?> <ServiceResponse RequestType=\"TEST\" CardAcceptorID=\"xx\" WorkstationID=\"xxx\" RequestID=\"4190_40a4f530-299e-4cc1-87de-0787ad920f93\" OverallResult=\"Success\" xmlns=\"http://www.nrf-arts.org/IXRetail/namespace\"/> "; var xmlParser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); var payloadBytes = new ByteArrayInputStream(bsMsg.getBytes(UTF_8)); var xml = xmlParser.parse(payloadBytes); var expression = XPathFactory.newInstance().newXPath().compile("//@RequestType"); out.println("evaluted >%s<".formatted(expression.evaluate(xml))); } }
Editor Settings
Theme
Key bindings
Full width
Lines