January 24, 2002 - The Browser's Response to XML Parsing Error
January 24, 2002 The Browser's Response to XML Parsing Error Tips: January 2002
Yehuda Shiran, Ph.D.
|
parseError
property is an object of the DOMDocument
. The properties of parseError
give an exact picture about the location of the parsing error. Let's look at an example. Here is an XML file with an error somewhere. Try locating it:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="mydvd.xsl"?>
<sales>
<summary>
<heading>MyDVD Rental Store</heading>
<subhead>Periodical Sales Report</subhead>
<description>Sales Report for January,
February, and March of 2001</description>
</summary>
<data>
<month>
<name>January 2001</name>
<week number="1" dvds_rented="12000" />
<week number="2" dvds_rented="15000" />
<week number="3" dvds_rented="18000" />
<week number="4" dvds_rented="11800" />
</month>
<month>
<name>February 2001</name>
<week number="1" dvds_rented="11500" />
<week number="2" dvds_rented="12390" />
<week number="3" dvds_rented="19050" />
<week number="4" dvds_rented="11200" />
</month>
<month>
<name>March 2001</name>
<week number="1" dvds_rented="15300" />
<week number="2" dvds_rented="12390" />
<week number="3" dvds_rented="10050" />
<week number="4" dvds_rented="11230" />
</month>
<data>
</sales>
Let your browser read the file now, and see which of parseError
's properties are used to show where the error is. See how the browser shows you graphically the location of the error (position 5 in line 32).