I'm parsing a XML file in this way that seems fine:
try {
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
XmlReader reader = XmlReader.Create(new XmlTextReader(filename), settings);
while (reader.Read()) {
switch (reader.NodeType) {
}
} catch (XmlException e) {
Console.WriteLine("error occured: " + e.Message);
}
The problem: I have a node like this:
The parser says no th the '<' and '>' inside the attribute;
How can afford it? (I need a way to don't get any error)
thanks
MarcoPosted Sep 22, 2009, 9:03 AM
mayank goyelPosted Sep 22, 2009, 12:57 AM
You code snippet is absolutly correct. The only problem is with your XML file. Actually, there are a few special characters for XML file like &, <, >, ", ' etc. You cannot use these characters directly in XML file. They have their own meaning and role in an XML file.
Therefore, you need to update your XML file. If you want to use these special characters, you need to use their entity references.
Here is the list:
Character Entity Reference
& &
< <
> >
" "
' '
You need to change your node from "List
Note: Please accept the answer if it solves your problem.