title: XML not getting parsed due to XML metadata tag
body: <p>I am trying to parse the XML and get to a node and delete is using the below code...</p>
  <pre><code>    DocumentBuilderFactory domBuilderFactory = DocumentBuilderFactory.newInstance();
      domBuilderFactory.setNamespaceAware(true);
      Document document = domBuilderFactory.newDocumentBuilder().parse(new InputSource(new StringReader(XML)));
      
      NodeList nodes = (NodeList) XPathFactory.newInstance().newXPath()
              .compile(&quot;/TrustFrameworkPolicy/BuildModel/RestSchema/CustType[starts-with(@Id, 'regular.Command-Nest.type')]&quot;)
              .evaluate(document, XPathConstants.NODESET);
      for (int i = 0; i &lt; nodes.getLength(); i++) {
          nodes.item(i).getParentNode().removeChild(nodes.item(i));
      }
  
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, &quot;yes&quot;);
      transformer.transform(new DOMSource(document), new StreamResult(System.out));
  </code></pre>
  <p>Below is the XML that I am parsing...but the problem is that I am not able to parse it because of the
  <strong>TrustFrameworkPolicy</strong> since it is long and has a lot of data...</p>
  <pre><code>&lt;TrustFrameworkPolicy xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
           xmlns=&quot;http://schemas.microsoft.com/online/cpim/schemas/2013/06&quot; PolicySchemaVersion=&quot;0.3.0.0&quot; TenantId=&quot;{Settings:Tenant}&quot; PolicyId=&quot;B2C_1A_User_MigrationClients&quot; PublicPolicyUri=&quot;http://{Settings:Tenant}/B2C_1A_User_MigrationClients&quot; DeploymentMode=&quot;{Settings:DeploymentMode}&quot; UserJourneyRecorderEndpoint=&quot;urn:journeyrecorder:applicationinsights&quot;&gt;
                &lt;BuildModel&gt;
                       &lt;RestSchema&gt;
                              &lt;CustType Id=&quot;regular.type1&quot;&gt;
                                    &lt;DataType&gt;string&lt;/DataType&gt;
                              &lt;/CustType&gt;
                              &lt;CustType Id=&quot;regular.type2&quot;&gt;
                                    &lt;DataType&gt;string&lt;/DataType&gt;
                              &lt;/CustType&gt;
                              &lt;CustType Id=&quot;regular.Command-Nest.type1&quot;&gt;
                                    &lt;DataType&gt;string&lt;/DataType&gt;
                              &lt;/CustType&gt;
                              &lt;CustType Id=&quot;regular.Command-Nest.type2&quot;&gt;
                                    &lt;DataType&gt;string&lt;/DataType&gt;
                              &lt;/CustType&gt;
                              &lt;CustType Id=&quot;regular.type3&quot;&gt;
                                    &lt;DataType&gt;string&lt;/DataType&gt;
                              &lt;/CustType&gt;
                              &lt;CustType Id=&quot;regular.Command-Nest.type4&quot;&gt;
                                    &lt;DataType&gt;string&lt;/DataType&gt;
                              &lt;/CustType&gt;
                       &lt;/RestSchema&gt;
                &lt;/BuildModel&gt;
          &lt;/TrustFrameworkPolicy&gt;
  </code></pre>
  <p><strong>BUT</strong> when I am testing by modifying the XML just to see if my java code is correct I am editing <strong>TrustFrameworkPolicy</strong> like this...<strong>IT IS WORKING FINE, I am able to parse and do my work</strong></p>
  <pre><code>&lt;TrustFrameworkPolicy xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
        xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
        &lt;BuildModel&gt;
               &lt;RestSchema&gt;
                      &lt;CustType Id=&quot;regular.type1&quot;&gt;
                            &lt;DataType&gt;string&lt;/DataType&gt;
                      &lt;/CustType&gt;
                      &lt;CustType Id=&quot;regular.type2&quot;&gt;
                            &lt;DataType&gt;string&lt;/DataType&gt;
                      &lt;/CustType&gt;
                      &lt;CustType Id=&quot;regular.Command-Nest.type1&quot;&gt;
                            &lt;DataType&gt;string&lt;/DataType&gt;
                      &lt;/CustType&gt;
                      &lt;CustType Id=&quot;regular.Command-Nest.type2&quot;&gt;
                            &lt;DataType&gt;string&lt;/DataType&gt;
                      &lt;/CustType&gt;
                      &lt;CustType Id=&quot;regular.type3&quot;&gt;
                            &lt;DataType&gt;string&lt;/DataType&gt;
                      &lt;/CustType&gt;
                      &lt;CustType Id=&quot;regular.Command-Nest.type4&quot;&gt;
                            &lt;DataType&gt;string&lt;/DataType&gt;
                      &lt;/CustType&gt;
               &lt;/RestSchema&gt;
        &lt;/BuildModel&gt;
  &lt;/TrustFrameworkPolicy&gt;
  </code></pre>
  <p><strong>OUTPUT</strong> (with updated TrustFrameworkPolicy tag)</p>
  <pre><code>&lt;TrustFrameworkPolicy xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; 
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
    &lt;BasePolicy&gt;
      &lt;TenantId&gt;egenginfob2cint.onmicrosoft.com&lt;/TenantId&gt;
      &lt;PolicyId&gt;B2C_1A_User_TrustFrameworkExtensions_MultiTenant&lt;/PolicyId&gt;
    &lt;/BasePolicy&gt;
    
    &lt;BuildingBlocks&gt;
      &lt;ClaimsSchema&gt;
        &lt;ClaimType Id=&quot;custom.rule1&quot;&gt;
          &lt;DataType&gt;string&lt;/DataType&gt;
        &lt;/ClaimType&gt;
        &lt;ClaimType Id=&quot;custom.rule2&quot;&gt;
          &lt;DataType&gt;string&lt;/DataType&gt;
        &lt;/ClaimType&gt;
        
        
        
        
      &lt;/ClaimsSchema&gt;
    &lt;/BuildingBlocks&gt;
  &lt;/TrustFrameworkPolicy&gt;
  </code></pre>
  <p>Can someone tell me what is happening and guide me how to get through this...or share a link that I can refer to.</p>