I am hoping someone on this list can shed some light on
the below issue for me. I am using XmlTextReader to read
from an XML file. Unfortunately, an exception is thrown
("Index was outside the bounds of the array.") when the
reader reaches the DOCTYPE. If I remove it everything
works fine. Should I be handling the DOCTYPE someway
before I read the DOCTYPE? Any insight would be greatly
appreciated. I have provided a sample XML document plus
some simple code.
Cheers,
------------------ Begin Document ------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ONIXmessage
SYSTEM "http://www.editeur.org/onix/2.0/short/onix-
international.dtd">
<ONIXmessage>
<header>
<m173>3983939393</m173>
<m174>Me Vendor</m174>
<m175>Full Name</m175>
<m180>1</m180>
<m182>200306221017</m182>
<m183>Description</m183>
</header>
<product>
<a001>0761501877</a001>
<a002>04</a002>
<b004>0761501877</b004>
<b005>9780761501862</b005>
<b012>BC</b012>
<b028>The Michael Story</b028>
<b029>What's It Like To Be Me</b029>
<contributor>
<b034>1</b034>
<b035>A01</b035>
<b036>Michael Muffett</b036>
<b037>Muffett, Michael</b037>
<b039>Michael</b039>
<b040>Muffett</b040>
<b043>L.</b043>
</contributor>
<b059>eng</b059>
<b061>1000</b061>
<b064>FIC000000</b064>
<b079>Muffett Publishing</b079>
<imprint>
<b241>02</b241>
<b243>PL</b243>
<b079>Muffett Publishing</b079>
</imprint>
<b081>Muffett Publishing</b081>
<b003>19951018</b003>
<supplydetail>
<j136>2013975</j136>
<j137>Random House</j137>
<j138>CA</j138>
<j141>IP</j141>
<j143>20031018</j143>
<j145>24</j145>
<price>
<j148>01</j148>
<j151>260.95</j151>
<j152>CAD</j152>
</price>
</supplydetail>
</product>
</ONIXmessage>
-------------------- End Document ----------------------
-------------------- Begin Code ------------------------
public static void loadDocument(string fileName)
{
XmlTextReader onixTextReader
= new XmlTextReader(fileName);
try
{
onixTextReader.Read();
MessageBox.Show("Declaration: " +
onixTextReader.NodeType.ToString());
onixTextReader.Read();
MessageBox.Show("Second
Line WhiteSpace: " + onixTextReader.NodeType.ToString());
onixTextReader.ReadString
();
MessageBox.Show
(onixTextReader.NodeType.ToString());
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
---------------------- End Code --------------------------