示例#1
0
        private async Task <XmlNodeStartTag> readXmlNodeStartTag()
        {
            int             nsRef           = buffer.getInt();
            int             nameRef         = buffer.getInt();
            XmlNodeStartTag xmlNodeStartTag = new XmlNodeStartTag();

            if (nsRef > 0)
            {
                xmlNodeStartTag.setNamespace(stringPool.get(nsRef));
            }
            xmlNodeStartTag.setName(stringPool.get(nameRef));

            // read attributes.
            // attributeStart and attributeSize are always 20 (0x14)
            int attributeStart = await Buffers.readUShort(buffer);

            int attributeSize = await Buffers.readUShort(buffer);

            int attributeCount = await Buffers.readUShort(buffer);

            int idIndex = await Buffers.readUShort(buffer);

            int classIndex = await Buffers.readUShort(buffer);

            int styleIndex = await Buffers.readUShort(buffer);

            // read attributes
            Attributes attributes = new Attributes(attributeCount);

            for (int count = 0; count < attributeCount; count++)
            {
                Attribute_ attribute = await readAttribute();

                if (xmlStreamer != null)
                {
                    string value = attribute.toStringValue(resourceTable, locale);
                    if (intAttributes.Contains(attribute.getName()) && Utils.isNumeric(value))
                    {
                        try
                        {
                            value = getFinalValueAsString(attribute.getName(), value);
                        }
                        catch
                        {
                            //ignore exception
                        }
                    }
                    attribute.setValue(value);
                    attributes.set(count, attribute);
                }
            }
            xmlNodeStartTag.setAttributes(attributes);

            if (xmlStreamer != null)
            {
                xmlStreamer.onStartTag(xmlNodeStartTag);
            }

            return(xmlNodeStartTag);
        }