¿Cómo puedo verificar si un nodo tiene un atributo particular o no?Compruebe si el nodo Xml tiene un atributo
Lo que hice es:
string referenceFileName = xmlFileName;
XmlTextReader textReader = new XmlTextReader(referenceFileName);
while (textReader.Read())
{
XmlNodeType nType = textReader.NodeType;
// if node type is an element
if (nType == XmlNodeType.Element)
{
if (textReader.Name.Equals("Control"))
{
if (textReader.AttributeCount >= 1)
{
String val = string.Empty;
val = textReader.GetAttribute("Visible");
if (!(val == null || val.Equals(string.Empty)))
{
}
}
}
}
¿Hay alguna función para comprobar que un determinado atributo está presente o no?
La palabra es "verificar", no "chk". – Oded