G
Guest
Exception: Index was outside the bounds of the array
at System.Xml.XmlTextReader.SetElementValues(
at System.Xml.XmlTextReader.ParseElement(
at System.Xml.XmlTextReader.Read(
at xmlReaderApp.Class1.Main(String[] args
The program handles more than 88 million Element XmlNodeType items and then throws the exception shown above. Could this be an issue
Here is the program..
using System
using System.Xml
using System.Collections
// This program reads an ASCII file of XML elements
// The output is a list of unique NODE TYPEs
// For example, <head> produces head in the output
// There is no validation of the XML
namespace xmlReaderAp
/// <summary
/// Summary description for Class1
/// </summary
class Class
/// <summary
/// The main entry point for the application
/// </summary
[STAThread
static void Main(string[] args
int symbolNumber=0
ArrayList arrayList = new ArrayList()
XmlTextReader xmlReader = new XmlTextReader(@"c:\1.xml")
tr
xmlReader.MoveToContent(); // Get beyond the DTD which we don't care abou
catch (Exception e
Console.WriteLine("Exception: " + e.Message); // handle undefined DT
try
while (xmlReader.Read())
symbolNumber++
if (symbolNumber % 100000 == 0
Console.WriteLine(symbolNumber)
switch (xmlReader.NodeType)
case XmlNodeType.Element
// Console.Write("<{0}>", xmlReader.Name)
bool bDoAdd = true
foreach (String memberofArrayList in arrayList
if (memberofArrayList.Equals(xmlReader.Name)
bDoAdd = false
break
if (bDoAdd
arrayList.Add(xmlReader.Name)
break
case XmlNodeType.Text
// Console.Write(xmlReader.Value)
break
case XmlNodeType.CDATA
// Console.Write("<![CDATA[{0}]]>", xmlReader.Value)
break
case XmlNodeType.ProcessingInstruction
// Console.Write("<?{0} {1}?>", xmlReader.Name, xmlReader.Value)
break
case XmlNodeType.Comment
// Console.Write("<!--{0}-->", xmlReader.Value)
break
case XmlNodeType.XmlDeclaration
// Console.Write("<?xml version='1.0'?>")
break
case XmlNodeType.Document
break
case XmlNodeType.DocumentType
// Console.Write("<!DOCTYPE {0} [{1}]", xmlReader.Name, xmlReader.Value)
break
case XmlNodeType.EntityReference
// Console.Write(xmlReader.Name)
break
case XmlNodeType.EndElement
// Console.Write("</{0}>", xmlReader.Name)
break
xmlReader.Close()
foreach (String memberofArrayList in arrayList
Console.WriteLine(memberofArrayList)
Console.WriteLine("This program has terminated.")
catch(Exception e)
xmlReader.Close()
Console.WriteLine("Exception: " + e.Message)
Console.WriteLine(e.StackTrace)
Console.WriteLine(e.Source)
foreach (String memberofArrayList in arrayList
Console.WriteLine(memberofArrayList)
Console.WriteLine("This program has terminated.")
return
at System.Xml.XmlTextReader.SetElementValues(
at System.Xml.XmlTextReader.ParseElement(
at System.Xml.XmlTextReader.Read(
at xmlReaderApp.Class1.Main(String[] args
The program handles more than 88 million Element XmlNodeType items and then throws the exception shown above. Could this be an issue
Here is the program..
using System
using System.Xml
using System.Collections
// This program reads an ASCII file of XML elements
// The output is a list of unique NODE TYPEs
// For example, <head> produces head in the output
// There is no validation of the XML
namespace xmlReaderAp
/// <summary
/// Summary description for Class1
/// </summary
class Class
/// <summary
/// The main entry point for the application
/// </summary
[STAThread
static void Main(string[] args
int symbolNumber=0
ArrayList arrayList = new ArrayList()
XmlTextReader xmlReader = new XmlTextReader(@"c:\1.xml")
tr
xmlReader.MoveToContent(); // Get beyond the DTD which we don't care abou
catch (Exception e
Console.WriteLine("Exception: " + e.Message); // handle undefined DT
try
while (xmlReader.Read())
symbolNumber++
if (symbolNumber % 100000 == 0
Console.WriteLine(symbolNumber)
switch (xmlReader.NodeType)
case XmlNodeType.Element
// Console.Write("<{0}>", xmlReader.Name)
bool bDoAdd = true
foreach (String memberofArrayList in arrayList
if (memberofArrayList.Equals(xmlReader.Name)
bDoAdd = false
break
if (bDoAdd
arrayList.Add(xmlReader.Name)
break
case XmlNodeType.Text
// Console.Write(xmlReader.Value)
break
case XmlNodeType.CDATA
// Console.Write("<![CDATA[{0}]]>", xmlReader.Value)
break
case XmlNodeType.ProcessingInstruction
// Console.Write("<?{0} {1}?>", xmlReader.Name, xmlReader.Value)
break
case XmlNodeType.Comment
// Console.Write("<!--{0}-->", xmlReader.Value)
break
case XmlNodeType.XmlDeclaration
// Console.Write("<?xml version='1.0'?>")
break
case XmlNodeType.Document
break
case XmlNodeType.DocumentType
// Console.Write("<!DOCTYPE {0} [{1}]", xmlReader.Name, xmlReader.Value)
break
case XmlNodeType.EntityReference
// Console.Write(xmlReader.Name)
break
case XmlNodeType.EndElement
// Console.Write("</{0}>", xmlReader.Name)
break
xmlReader.Close()
foreach (String memberofArrayList in arrayList
Console.WriteLine(memberofArrayList)
Console.WriteLine("This program has terminated.")
catch(Exception e)
xmlReader.Close()
Console.WriteLine("Exception: " + e.Message)
Console.WriteLine(e.StackTrace)
Console.WriteLine(e.Source)
foreach (String memberofArrayList in arrayList
Console.WriteLine(memberofArrayList)
Console.WriteLine("This program has terminated.")
return