title: How to run XmlParser / Read XML in Jenkins declarative pipeline
body: <p>I have the following in a Jenkins file where I am trying to get some text from an XML file:</p>
  <pre><code>    pipeline {
        agent any
        stages {
          stage('Start') {
            steps {
              echo 'Build start'  
              script {
                def xml = readFile &quot;${env.WORKSPACE}/config.xml&quot;
                def xmlContents = new XmlParser().parseText(xml)
                def text = xmlContents.text()
                echo 'contents are...'
                echo text
                
              }
            }
          }
      .....
  </code></pre>
  <p>This causes the following exception</p>
  <pre><code>    org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.util.XmlParser parseText java.lang.String
          at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:262)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:161)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:156)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:160)
          at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
          at WorkflowScript.run(WorkflowScript:9)
  </code></pre>
  <p>According to a solution to this problem as posted <a href="https://stackoverflow.com/questions/38276341/jenkins-ci-pipeline-scripts-not-permitted-to-use-method-groovy-lang-groovyobject">here</a>, I need to go in and set the <code> In-process Script Approval</code>, however I have done this a couple of times..</p>
  <p><a href="https://i.stack.imgur.com/JiTu0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JiTu0.png" alt="enter image description here" /></a></p>
  <p>Also, elsewhere, I have seen comments to disable sandbox mode, but I do not have this option as shown in other screen shots...</p>
  <p><a href="https://i.stack.imgur.com/W4Y5W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W4Y5W.png" alt="enter image description here" /></a></p>
  <p>Perhaps things have changed.</p>
  <p>So, my question is, how can I read the contents of an XML file if can't use the XMLParser? Or how can I use the XMLParser?</p>