Hello, I'm doing something ike this under to read a file HTML (not xml; hope this will be fine); by the way the problem is when I read the namespace, the xmlreader crash at runtime; how can I solve this?
thanks
public Parser(string fileContent) { _settings.ConformanceLevel = ConformanceLevel.Fragment; _settings.IgnoreWhitespace = true; _settings.IgnoreComments = true; _textReader = XmlReader.Create(fileContent, _settings); _textReader.Read(); XmlNodeType nType = _textReader.NodeType; while (_textReader.Read()) { switch (_textReader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + _textReader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine(_textReader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + _textReader.Name); Console.WriteLine(">"); break; } }
<html> <head></head> <body> <using xmlns:namespace="myfile" /> myText <p><namespace:myComponent Attribs="val"> //it crashes on ' namespace:myCOmponent' </body> </html>
|