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.d td">
<ONIXmessage>
<header>
<m173>398393939 3</m173>
<m174>Me Vendor</m174>
<m175>Full Name</m175>
<m180>1</m180>
<m182>200306221 017</m182>
<m183>Descripti on</m183>
</header>
<product>
<a001>076150187 7</a001>
<a002>04</a002>
<b004>076150187 7</b004>
<b005>978076150 1862</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>1995101 8</b003>
<supplydetail >
<j136>2013975 </j136>
<j137>Random House</j137>
<j138>CA</j138>
<j141>IP</j141>
<j143>2003101 8</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(st ring fileName)
{
XmlTextReader onixTextReader
= new XmlTextReader(f ileName);
try
{
onixTextReader. Read();
MessageBox.Show ("Declaratio n: " +
onixTextReader. NodeType.ToStri ng());
onixTextReader. Read();
MessageBox.Show ("Second
Line WhiteSpace: " + onixTextReader. NodeType.ToStri ng());
onixTextReader. ReadString
();
MessageBox.Show
(onixTextReader .NodeType.ToStr ing());
}
catch(Exception e)
{
MessageBox.Show (e.Message);
}
---------------------- End Code --------------------------
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.d td">
<ONIXmessage>
<header>
<m173>398393939 3</m173>
<m174>Me Vendor</m174>
<m175>Full Name</m175>
<m180>1</m180>
<m182>200306221 017</m182>
<m183>Descripti on</m183>
</header>
<product>
<a001>076150187 7</a001>
<a002>04</a002>
<b004>076150187 7</b004>
<b005>978076150 1862</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>1995101 8</b003>
<supplydetail >
<j136>2013975 </j136>
<j137>Random House</j137>
<j138>CA</j138>
<j141>IP</j141>
<j143>2003101 8</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(st ring fileName)
{
XmlTextReader onixTextReader
= new XmlTextReader(f ileName);
try
{
onixTextReader. Read();
MessageBox.Show ("Declaratio n: " +
onixTextReader. NodeType.ToStri ng());
onixTextReader. Read();
MessageBox.Show ("Second
Line WhiteSpace: " + onixTextReader. NodeType.ToStri ng());
onixTextReader. ReadString
();
MessageBox.Show
(onixTextReader .NodeType.ToStr ing());
}
catch(Exception e)
{
MessageBox.Show (e.Message);
}
---------------------- End Code --------------------------
Comment