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>
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>