R
Ron
I think this code is almost working but I get the following error:
Error 1 Cannot convert type 'string' to 'System.Xml.XmlAttribute' C:
\Spring 2007\C#\convertxml\convertxml\Form1.cs 35 15 convertxml
ths is what is underlined in blue:
(XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/@NAME").Value =
newvalue;
this is my whole code:
private void btnConvert_Click(object sender, EventArgs e)
{
// Get a directory
string path = @"c:\WAMP\";
foreach (string fileName in Directory.GetFiles(path,
"*.xml"))
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(fileName);
string newvalue =
((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Application_Data/
Application_Info[@AI_TYPE='ETS_ADVERTISER']/Ai_Item/
@NAME")).Value.tostring;
(XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/
@NAME").Value = newvalue;
xdoc.Save(fileName);
}
}
How can I fix this error?
Error 1 Cannot convert type 'string' to 'System.Xml.XmlAttribute' C:
\Spring 2007\C#\convertxml\convertxml\Form1.cs 35 15 convertxml
ths is what is underlined in blue:
(XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/@NAME").Value =
newvalue;
this is my whole code:
private void btnConvert_Click(object sender, EventArgs e)
{
// Get a directory
string path = @"c:\WAMP\";
foreach (string fileName in Directory.GetFiles(path,
"*.xml"))
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(fileName);
string newvalue =
((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Application_Data/
Application_Info[@AI_TYPE='ETS_ADVERTISER']/Ai_Item/
@NAME")).Value.tostring;
(XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/
@NAME").Value = newvalue;
xdoc.Save(fileName);
}
}
How can I fix this error?