J
Jason Barnett
I'm having a problem with converting an XMLNode attribute on one machine, but
not another. I've opened an XML file using a XMLDocument object, and I've
navigated through it, processing various data. All other XMLNode attributes
for the problematic element parse fine (they are strings and do not have to
be converted). However, the attribute that I'm having problems with is a
string representation of a boolean ("True") and an error is thrown, only on
one machine, when converting it to a boolean.
Does anyone know why? Can you recommend a solution? Here is a code snippet
relating to what I'm attempting:
static void Main(string[] args)
{
bool isRequired = Convert.ToBoolean(GetAttributeValue(node, "required"));
}
private string GetAttributeValue(XmlNode node, string attributeName)
{
if (node.Attributes != null &&
node.Attributes.GetNamedItem(attributeName) != null)
{
return node.Attributes.GetNamedItem(attributeName).Value;
}
else
{
return string.Empty;
}
}
not another. I've opened an XML file using a XMLDocument object, and I've
navigated through it, processing various data. All other XMLNode attributes
for the problematic element parse fine (they are strings and do not have to
be converted). However, the attribute that I'm having problems with is a
string representation of a boolean ("True") and an error is thrown, only on
one machine, when converting it to a boolean.
Does anyone know why? Can you recommend a solution? Here is a code snippet
relating to what I'm attempting:
static void Main(string[] args)
{
bool isRequired = Convert.ToBoolean(GetAttributeValue(node, "required"));
}
private string GetAttributeValue(XmlNode node, string attributeName)
{
if (node.Attributes != null &&
node.Attributes.GetNamedItem(attributeName) != null)
{
return node.Attributes.GetNamedItem(attributeName).Value;
}
else
{
return string.Empty;
}
}