Hello,
I must implement a such parser (based on a LL(1) grammar). I did this
try {
// Create the reader.
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
XmlReader reader = XmlReader.Create(new XmlTextReader(filename), settings);
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
Hashtable attributes = new Hashtable();
string strURI = reader.NamespaceURI;
string strName = reader.Name;
Console.Write(strURI + " " + "<" + strName );
if (reader.HasAttributes) {
for (int i = 0; i < reader.AttributeCount; i++) {
reader.MoveToAttribute(i);
attributes.Add(reader.Name, reader.Value);
Console.Write(" " + reader.Name + "=" + "\"" + reader.Value + "\"");
}
Console.WriteLine(">");
}
else {
Console.WriteLine(">");
}
break;
case XmlNodeType.EndElement:
string strNameEND = reader.Name;
Console.WriteLine("</" + strNameEND + ">");
break;
// Todo
//case XmlNodeType.Text:
// Todo
default:
break;
}
}
Can I say that using SAx I'm doing a recursive descent parser or not?
thanks