Esempio n. 1
0
 public void SetAttributes(IAttributes attributes)
 {
     this.Clear();
     length = attributes.GetLength();
     if (length > 0)
     {
         data = new string[length * 5];
         for (int i = 0; i < length; i++)
         {
             data[i * 5]     = attributes.GetURI(i);
             data[i * 5 + 1] = attributes.GetLocalName(i);
             data[i * 5 + 2] = attributes.GetQName(i);
             data[i * 5 + 3] = attributes.GetType(i);
             data[i * 5 + 4] = attributes.GetValue(i);
         }
     }
 }
Esempio n. 2
0
	    /// <summary>
	    /// <para>Receive notification of the beginning of an element.</para><para>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.</para><para>This event allows up to three name components for each element:</para><para><ol><li><para>the Namespace URI; </para></li><li><para>the local name; and </para></li><li><para>the qualified (prefixed) name. </para></li></ol></para><para>Any or all of these may be provided, depending on the values of the <b></b> and the <b></b> properties:</para><para><ul><li><para>the Namespace URI and local name are required when the namespaces property is <b>true</b> (the default), and are optional when the namespaces property is <b>false</b> (if one is specified, both must be); </para></li><li><para>the qualified name is required when the namespace-prefixes property is <b>true</b>, and is optional when the namespace-prefixes property is <b>false</b> (the default). </para></li></ul></para><para>Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the <code></code> property is true (it is false by default, and support for a true value is optional).</para><para>Like characters(), attribute values may have characters that need more than one <code>char</code> value. </para><para><para>endElement </para><simplesectsep></simplesectsep><para>org.xml.sax.Attributes </para><simplesectsep></simplesectsep><para>org.xml.sax.helpers.AttributesImpl </para></para>        
	    /// </summary>
	    public void StartElement(string uri, string localName, string qName, IAttributes atts)
	    {
	        var element = new XElement(XName.Get(localName, uri));
	        var parent = elementStack.Empty() ? null : elementStack.Peek();
	        if (parent == null)
	        {
	            document.Add(element);
	        }
	        else
	        {
	            parent.Add(element);
	        }
	        var attrCount = atts.GetLength();
	        for (var i = 0; i < attrCount; i++)
	        {
	            var name = XName.Get(atts.GetLocalName(i), atts.GetURI(i));
	            var attr = new XAttribute(name, atts.GetValue(i));
	            element.Add(attr);
	        }
	        elementStack.Push(element);
	    }
Esempio n. 3
0
        /// <summary>
        /// <para>Receive notification of the beginning of an element.</para><para>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.</para><para>This event allows up to three name components for each element:</para><para><ol><li><para>the Namespace URI; </para></li><li><para>the local name; and </para></li><li><para>the qualified (prefixed) name. </para></li></ol></para><para>Any or all of these may be provided, depending on the values of the <b></b> and the <b></b> properties:</para><para><ul><li><para>the Namespace URI and local name are required when the namespaces property is <b>true</b> (the default), and are optional when the namespaces property is <b>false</b> (if one is specified, both must be); </para></li><li><para>the qualified name is required when the namespace-prefixes property is <b>true</b>, and is optional when the namespace-prefixes property is <b>false</b> (the default). </para></li></ul></para><para>Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the <code></code> property is true (it is false by default, and support for a true value is optional).</para><para>Like characters(), attribute values may have characters that need more than one <code>char</code> value. </para><para><para>endElement </para><simplesectsep></simplesectsep><para>org.xml.sax.Attributes </para><simplesectsep></simplesectsep><para>org.xml.sax.helpers.AttributesImpl </para></para>
        /// </summary>
        public void StartElement(string uri, string localName, string qName, IAttributes atts)
        {
            var element = new XElement(XName.Get(localName, uri));
            var parent  = elementStack.Empty() ? null : elementStack.Peek();

            if (parent == null)
            {
                document.Add(element);
            }
            else
            {
                parent.Add(element);
            }
            var attrCount = atts.GetLength();

            for (var i = 0; i < attrCount; i++)
            {
                var name = XName.Get(atts.GetLocalName(i), atts.GetURI(i));
                var attr = new XAttribute(name, atts.GetValue(i));
                element.Add(attr);
            }
            elementStack.Push(element);
        }