• Register
31,120 points
10 6 4

Solution:

To solve this problem you have to follw the below steps. First thing first, running with a SAX-style element parser and the XmlTextReader class built with XmlReader. Follw this below code carefully

Code:

void ParseURL(string strUrl)
{
  try
  {
    using (var reader = XmlReader.Create(strUrl))
    {
      while (reader.Read())
      {
        switch (reader.NodeType)
        {
          case XmlNodeType.Element:
            var attributes = new Hashtable();
            var strURI = reader.NamespaceURI;
            var strName = reader.Name;
            if (reader.HasAttributes)
            {
              for (int i = 0; i < reader.AttributeCount; i++)
              {
                reader.MoveToAttribute(i);
                attributes.Add(reader.Name,reader.Value);
              }
            }
            StartElement(strURI,strName,strName,attributes);
            break;
            //
            //you can handle other cases here
            //
            //case XmlNodeType.EndElement:
            // Todo
            //case XmlNodeType.Text:
            // Todo
            default:
            break;
          }
        }
      }
      catch (XmlException e)
      {
        Console.WriteLine("error occured: " + e.Message);
      }
    }
  }
}

 

Or, You can follow the below method

In your current file:

using (var reader = new XmlReader.Create(strUrl))

To Fix:

using (var reader = XmlReader.Create(strUrl))

 

31,120 points
10 6 4