public static String decompressXML(byte[] xml){
  StringBuilder resultXml=new StringBuilder();
  int numbStrings=LEW(xml,4 * 4);
  int sitOff=0x24;
  int stOff=sitOff + numbStrings * 4;
  int xmlTagOff=LEW(xml,3 * 4);
  for (int ii=xmlTagOff; ii < xml.length - 4; ii+=4) {
    if (LEW(xml,ii) == startTag) {
      xmlTagOff=ii;
      break;
    }
  }
  int off=xmlTagOff;
  int indent=0;
  while (off < xml.length) {
    int tag0=LEW(xml,off);
    int lineNo=LEW(xml,off + 2 * 4);
    int nameNsSi=LEW(xml,off + 4 * 4);
    int nameSi=LEW(xml,off + 5 * 4);
    if (tag0 == startTag) {
      int tag6=LEW(xml,off + 6 * 4);
      int numbAttrs=LEW(xml,off + 7 * 4);
      off+=9 * 4;
      String name=compXmlString(xml,sitOff,stOff,nameSi);
      StringBuffer sb=new StringBuffer();
      for (int ii=0; ii < numbAttrs; ii++) {
        int attrNameNsSi=LEW(xml,off);
        int attrNameSi=LEW(xml,off + 1 * 4);
        int attrValueSi=LEW(xml,off + 2 * 4);
        int attrFlags=LEW(xml,off + 3 * 4);
        int attrResId=LEW(xml,off + 4 * 4);
        off+=5 * 4;
        String attrName=compXmlString(xml,sitOff,stOff,attrNameSi);
        String attrValue=attrValueSi != -1 ? compXmlString(xml,sitOff,stOff,attrValueSi) : M.e("resourceID 0x") + Integer.toHexString(attrResId);
        sb.append(" " + attrName + "=\""+ attrValue+ "\"");
      }
      resultXml.append(prtIndent(indent,"<" + name + sb+ ">"));
      indent++;
    }
 else     if (tag0 == endTag) {
      indent--;
      off+=6 * 4;
      String name=compXmlString(xml,sitOff,stOff,nameSi);
      resultXml.append(prtIndent(indent,"</" + name + ">\n"));
    }
 else     if (tag0 == endDocTag) {
      break;
    }
 else {
      if (Cfg.DEBUG) {
        Check.log(TAG + " (decompressXML): Unrecognized tag code '" + Integer.toHexString(tag0)+ "' at offset "+ off);
      }
      break;
    }
  }
  if (Cfg.DEBUG) {
    Check.log(TAG + " (decompressXML):   end at offset " + off);
  }
  return resultXml.toString();
}

public static String decompressXML ( byte [ ] xml ) { StringBuilder resultXml = new StringBuilder ( ) ; int numbStrings = LEW ( xml , 4 * 4 ) ; int sitOff = 0x24 ; int stOff = sitOff + numbStrings * 4 ; int xmlTagOff = LEW ( xml , 3 * 4 ) ; for ( int ii = xmlTagOff ; ii < xml . length - 4 ; ii += 4 ) { if ( LEW ( xml , ii ) == startTag ) { xmlTagOff = ii ; break ; } } int off = xmlTagOff ; int indent = 0 ; while ( off < xml . length ) { int tag0 = LEW ( xml , off ) ; int lineNo = LEW ( xml , off + 2 * 4 ) ; int nameNsSi = LEW ( xml , off + 4 * 4 ) ; int nameSi = LEW ( xml , off + 5 * 4 ) ; if ( tag0 == startTag ) { int tag6 = LEW ( xml , off + 6 * 4 ) ; int numbAttrs = LEW ( xml , off + 7 * 4 ) ; off += 9 * 4 ; String name = compXmlString ( xml , sitOff , stOff , nameSi ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int ii = 0 ; ii < numbAttrs ; ii ++ ) { int attrNameNsSi = LEW ( xml , off ) ; int attrNameSi = LEW ( xml , off + 1 * 4 ) ; int attrValueSi = LEW ( xml , off + 2 * 4 ) ; int attrFlags = LEW ( xml , off + 3 * 4 ) ; int attrResId = LEW ( xml , off + 4 * 4 ) ; off += 5 * 4 ; String attrName = compXmlString ( xml , sitOff , stOff , attrNameSi ) ; String attrValue = attrValueSi != - 1 ? compXmlString ( xml , sitOff , stOff , attrValueSi ) : M . e ( "resourceID 0x" ) + Integer . toHexString ( attrResId ) ; sb . append ( " " + attrName + "=\"" + attrValue + "\"" ) ; } resultXml . append ( prtIndent ( indent , "<" + name + sb + ">" ) ) ; indent ++ ; } else if ( tag0 == endTag ) { indent -- ; off += 6 * 4 ; String name = compXmlString ( xml , sitOff , stOff , nameSi ) ; resultXml . append ( prtIndent ( indent , "</" + name + ">\n" ) ) ; } else if ( tag0 == endDocTag ) { break ; } else { if ( Cfg . DEBUG ) { Check . log ( TAG + " (decompressXML): Unrecognized tag code '" + Integer . toHexString ( tag0 ) + "' at offset " + off ) ; } break ; } } if ( Cfg . DEBUG ) { Check . log ( TAG + " (decompressXML):   end at offset " + off ) ; } return resultXml . toString ( ) ; }
parse the ' compressed ' binary form of android xml docs such as for androidmanifest . xml in . apk files source : http : / / stackoverflow . com / questions / 2097813 / how - to - parse - the - androidmanifest - xml - file - inside - an - apk - package / 4761689 # 4761689
