Search code examples
c#xmlxmlreader

xmlreader, get the attribute's name


I want to do something like:

stringBuilder.AppendLine("   globalVar." + reader.GetAttribute(i).Name + " = " + reader[i] + "; //add param ");

Where "reader.GetAttribute(i).Name" is the component that doesn't work. Is there an equivalent method to get the name of an attribute?


Solution

  • Use reader.MoveToAttribute(i), then you can use reader.Name and reader.Value.