System.Xml.XmlTextReaderImpl.ReadAttributeValue C# (CSharp) Method

ReadAttributeValue() public method

public ReadAttributeValue ( ) : bool
return bool
        public override bool ReadAttributeValue()
        {
            if (_parsingFunction != ParsingFunction.InReadAttributeValue)
            {
                if (_curNode.type != XmlNodeType.Attribute)
                {
                    return false;
                }
                if (_readState != ReadState.Interactive || _curAttrIndex < 0)
                {
                    return false;
                }
                if (_parsingFunction == ParsingFunction.InReadValueChunk)
                {
                    FinishReadValueChunk();
                }
                if (_parsingFunction == ParsingFunction.InReadContentAsBinary)
                {
                    FinishReadContentAsBinary();
                }

                if (_curNode.nextAttrValueChunk == null || _entityHandling == EntityHandling.ExpandEntities)
                {
                    NodeData simpleValueNode = AddNode(_index + _attrCount + 1, _curNode.depth + 1);
                    simpleValueNode.SetValueNode(XmlNodeType.Text, _curNode.StringValue);
                    simpleValueNode.lineInfo = _curNode.lineInfo2;
                    simpleValueNode.depth = _curNode.depth + 1;
                    _curNode = simpleValueNode;

                    simpleValueNode.nextAttrValueChunk = null;
                }
                else
                {
                    _curNode = _curNode.nextAttrValueChunk;

                    // Place the current node at nodes[index + attrCount + 1]. If the node type
                    // is be EntityReference and user calls ResolveEntity, the associated EndEntity
                    // node will be constructed from the information stored there.

                    // This will initialize the (index + attrCount + 1) place in nodes array
                    AddNode(_index + _attrCount + 1, _index + 2);
                    _nodes[_index + _attrCount + 1] = _curNode;

                    _fullAttrCleanup = true;
                }
                _nextParsingFunction = _parsingFunction;
                _parsingFunction = ParsingFunction.InReadAttributeValue;
                _attributeValueBaseEntityId = _ps.entityId;
                return true;
            }
            else
            {
                if (_ps.entityId == _attributeValueBaseEntityId)
                {
                    if (_curNode.nextAttrValueChunk != null)
                    {
                        _curNode = _curNode.nextAttrValueChunk;
                        _nodes[_index + _attrCount + 1] = _curNode;  // if curNode == EntityReference node, it will be picked from here by SetupEndEntityNodeInAttribute
                        return true;
                    }
                    return false;
                }
                else
                {
                    // expanded entity in attribute value
                    return ParseAttributeValueChunk();
                }
            }
        }

Usage Example

示例#1
0
 public override bool ReadAttributeValue()
 {
     return(_impl.ReadAttributeValue());
 }
XmlTextReaderImpl