I have some simple HTML I'm trying to read with the XMLTextReader. As in the
MSDS examples, I set up a loop to read each XML node:
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
Console.WriteLine("<{0}>", reader.Name);
break;
case XmlNodeType.Text:
Console.WriteLine(reader.Value);
break;
case XmlNodeType.Attribute:
Console.WriteLine(reader.Value);
break;
default:
Console.WriteLine(reader.NodeType);
break;
}
}
The reader moves along fine until it attempts to read the </head> node. in
this html:
<html>
<head>
<title>Sir</title>
<meta name="Author" content="Bar01">
<meta name="Description" content="Instructions">
<link href="css/results.css" media="SCREEN" rel="StyleSheet"
type="text/css" />
</head>
The error is:
System.Xml.XmlException: The 'meta' start tag on line '5' does
not match the end tag of 'head'. Line 7, position 4.
at System.Xml.XmlTextReader.ParseTag()
at System.Xml.XmlTextReader.ParseBeginTagExpandCharEn tities()
at System.Xml.XmlTextReader.Read()
at PIDProvider.Analyze.PIDrefs() in c:\vdev2\PID\Analysis.cs:line 29
What does that exception mean?
Am I missing something? Am I wrong to assume that I can read the HTML with
the XMLTextReader?
Thanks
Mitch