public int next() throws IOException {
        if (fileSize < 0) {
            int type = in.getInt() & 0xFFFF;
            if (type != RES_XML_TYPE) {
                throw new RuntimeException();
            }
            fileSize = in.getInt();
            return START_FILE;
        }
        int event = -1;
        for (int p = in.position(); p < fileSize; p = in.position()) {
            int type = in.getInt() & 0xFFFF;
            int size = in.getInt();
            switch (type) {
                case RES_XML_START_ELEMENT_TYPE: {
                    {
                        lineNumber = in.getInt();
                        in.getInt();/* skip, 0xFFFFFFFF */
                        nsIdx = in.getInt();
                        nameIdx = in.getInt();
                        int flag = in.getInt();// 0x00140014 ?
                        if (flag != 0x00140014) {
                            throw new RuntimeException();
                        }
                    }

                    attributeCount = in.getShort() & 0xFFFF;
                    idAttribute = (in.getShort() & 0xFFFF) - 1;
                    classAttribute = (in.getShort() & 0xFFFF) - 1;
                    styleAttribute = (in.getShort() & 0xFFFF) - 1;

                    attrs = in.asIntBuffer();

                    // attrResId = new int[attributeCount];
                    // attrName = new int[attributeCount];
                    // attrNs = new int[attributeCount];
                    // attrType = new int[attributeCount];
                    // attrValue = new Object[attributeCount];
                    // for (int i = 0; i < attributeCount; i++) {
                    // int attrNsIdx = in.getInt();
                    // int attrNameIdx = in.getInt();
                    // int raw = in.getInt();
                    // int aValueType = in.getInt() >>> 24;
                    // int aValue = in.getInt();
                    // Object value = null;
                    // switch (aValueType) {
                    // case TYPE_STRING:
                    // value = strings[aValue];
                    // break;
                    // case TYPE_INT_BOOLEAN:
                    // value = aValue != 0;
                    // break;
                    // default:
                    // value = aValue;
                    // }
                    // int resourceId = attrNameIdx < this.resourceIds.length ?
                    // resourceIds[attrNameIdx] : -1;
                    // attrNs[i] = attrNsIdx;
                    // attrName[i] = attrNameIdx;
                    // attrType[i] = aValueType;
                    // attrResId[i] = resourceId;
                    // attrValue[i] = value;
                    // }
                    event = START_TAG;
                }
                break;
                case RES_XML_END_ELEMENT_TYPE: {
                    in.position(p + size);
                    event = END_TAG;
                }
                break;
                case RES_XML_START_NAMESPACE_TYPE:
                    lineNumber = in.getInt();
                    in.getInt();/* 0xFFFFFFFF */
                    prefixIdx = in.getInt();
                    nsIdx = in.getInt();
                    event = START_NS;
                    break;
                case RES_XML_END_NAMESPACE_TYPE:
                    in.position(p + size);
                    event = END_NS;
                    break;
                case RES_STRING_POOL_TYPE:
                    strings = StringItems.read(in);
                    in.position(p + size);
                    continue;
                case RES_XML_RESOURCE_MAP_TYPE:
                    int count = size / 4 - 2;
                    resourceIds = new int[count];
                    for (int i = 0; i < count; i++) {
                        resourceIds[i] = in.getInt();
                    }
                    in.position(p + size);
                    continue;
                case RES_XML_CDATA_TYPE:
                    lineNumber = in.getInt();
                    in.getInt();/* 0xFFFFFFFF */
                    textIdx = in.getInt();

                    in.getInt();/* 00000008 00000000 */
                    in.getInt();

                    event = TEXT;
                    break;
                default:
                    throw new RuntimeException();
            }
            in.position(p + size);
            return event;
        }
        return END_FILE;
    }
a class to read android axml

@author <a href="mailto:pxb1988@gmail.com">Panxiaobo</a>
android/third_party/apkbuilder/src/main/java/pxb/android/axml/AxmlParser.java