Esempio n. 1
0
 public override void EndElement(string uri, string localName, string qName)
 {
     if (inBODY > 0)
     {
         if ("body".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             inBODY--;
         }
         else if (ENDLINE_ELEMENTS.Contains(localName))
         {
             body.Append('\n');
         }
         else if (SUPPRESS_ELEMENTS.Contains(localName))
         {
             suppressed--;
         }
     }
     else if (inHEAD > 0)
     {
         if ("head".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             inHEAD--;
         }
         else if (inTITLE > 0 && "title".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             inTITLE--;
         }
     }
 }
Esempio n. 2
0
 public override void StartElement(string uri, string localName, string qName, IAttributes atts)
 {
     if (inHEAD > 0)
     {
         if ("title".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             inTITLE++;
         }
         else
         {
             if ("meta".Equals(localName, StringComparison.OrdinalIgnoreCase))
             {
                 string name = atts.GetValue("name");
                 if (name == null)
                 {
                     name = atts.GetValue("http-equiv");
                 }
                 string val = atts.GetValue("content");
                 if (name != null && val != null)
                 {
                     outerInstance.metaTags[name.ToLowerInvariant()] = val;
                 }
             }
         }
     }
     else if (inBODY > 0)
     {
         if (SUPPRESS_ELEMENTS.Contains(localName))
         {
             suppressed++;
         }
         else if ("img".Equals(localName, StringComparison.OrdinalIgnoreCase))
         {
             // the original javacc-based parser preserved <IMG alt="..."/>
             // attribute as body text in [] parenthesis:
             string alt = atts.GetValue("alt");
             if (alt != null)
             {
                 body.Append('[').Append(alt).Append(']');
             }
         }
     }
     else if ("body".Equals(localName, StringComparison.OrdinalIgnoreCase))
     {
         inBODY++;
     }
     else if ("head".Equals(localName, StringComparison.OrdinalIgnoreCase))
     {
         inHEAD++;
     }
     else if ("frameset".Equals(localName, StringComparison.OrdinalIgnoreCase))
     {
         throw new SAXException("This parser does not support HTML framesets.");
     }
 }