Now I'm even more confused.
I tried the TestApp and it worked fine.
Again I doublechecked my app - I still get null returned for reader.GetAttribute("Type"
and a false for reader.HasAttributes.
The only thing that's different is that I'm not creating the XmlTextReader from
a file. But that shouldn't make a difference, should it?
I'm at a loss.
Is there another way that I can get this data, perhaps not using XmlTextReader?
Main Topics
Browse All Topics





by: dualsoulPosted on 2005-01-25 at 10:19:39ID: 13134804
hm...not sure what doesn't work with your code.
Mode.OpenO rCreate));
lNodeType. Element)) {
ne("DateTi e"); eName"); eNumber"); "); te @type: "+reader.GetAttribute("Typ e"));
It seems absolutely allright :)
here the my test class, check it yourself:
using System;
using System.Xml;
using System.IO;
namespace ConsoleApplication1 {
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1 {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args) {
XmlTextReader reader = new XmlTextReader(new FileStream("test.xml",File
while (reader.Read()) {
if (reader.NodeType.Equals(Xm
switch (reader.Name) {
case "Name": Console.WriteLine("Name");
break;
case "DateTime":Console.WriteLi
break;
case "MachineName" :Console.WriteLine("Machin
break;
case "MessageNumber" :Console.WriteLine("Messag
break;
case "Detail": Console.WriteLine("Details
if (reader.HasAttributes) // This fails every time
Console.WriteLine("Attribu
break;
}
}
}
}
}
}