title: Print Soap Body data using lxml
body: <p>I have a following XML . I need to store whole body xml from the Soap request in a variable .</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cre="http://www.code.com/abc/V1/createCase"&gt;
     &lt;soapenv:Header&gt;&lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/2" xmlns:wsu="http://docs.oasis-open.org/a.xsd"&gt;&lt;/wsse:Security&gt;
     &lt;/soapenv:Header&gt;
     &lt;soapenv:Body xmlns:wsu="http://docs.oasis-open.org/30.xsd" wsu:Id="id-14"&gt;
        &lt;cre:createCase&gt;
           &lt;cre:Request&gt;
              &lt;cre:ServiceAttributesGrp&gt;
                 &lt;cre:MinorVer&gt;?&lt;/cre:MinorVer&gt;
              &lt;/cre:ServiceAttributesGrp&gt;
              &lt;cre:CreateCaseReqGrp&gt;
                 &lt;cre:Language&gt;English&lt;/cre:Language&gt;
                 &lt;cre:CustFirstNm&gt;Issue&lt;/cre:CustFirstNm&gt;
                 &lt;cre:CustLastNm&gt;Detection&lt;/cre:CustLastNm&gt;
                 &lt;cre:AddlDynInfoGrp&gt;
                    &lt;cre:AddlDynInfo&gt;
                             &lt;cre:FieldNm&gt;TM3&lt;/cre:FieldNm&gt;
                             &lt;cre:FieldVal&gt;&lt;/cre:FieldVal&gt;
                    &lt;/cre:AddlDynInfo&gt;
                    &lt;cre:AddlDynInfo&gt;
                             &lt;cre:FieldNm&gt;PM417&lt;/cre:FieldNm&gt;
                             &lt;cre:FieldVal&gt;Not Defined&lt;/cre:FieldVal&gt;
                    &lt;/cre:AddlDynInfo&gt;
                 &lt;/cre:AddlDynInfoGrp&gt;
                 &lt;cre:CreateCriteriasGrp&gt;
                    &lt;cre:CreateCriterias&gt;
                       &lt;cre:CriteriaNm&gt;CriticalReqDtlValidationReqd&lt;/cre:CriteriaNm&gt;
                    &lt;/cre:CreateCriterias&gt;
                 &lt;/cre:CreateCriteriasGrp&gt;
              &lt;/cre:CreateCaseReqGrp&gt;
           &lt;/cre:Request&gt;
        &lt;/cre:createCase&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>As of now I am trying to print in the following manner , but I am unable to : </p>
  
  <pre><code>ns = {'cre': 'http://www.americanexpress.com/worldservice/CLIC/CaseManagementService/V1/createCase' , 'soapenv':'http://schemas.xmlsoap.org/soap/envelope/'}
       tree = etree.parse(template_xml)
       root = tree.getroot()
       for bodytag in root.xpath('soapenv:Body/cre:createCase',namespaces=ns):
         print bodytag
         datalevel = etree.XPathEvaluator(bodytag,namespaces=ns)
         print datalevel('cre:createCase').text()
  </code></pre>
  
  <p>I just need to print the createCase part .</p>