This code is almost doing what I want it to do, here is the 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);
((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/
@NAME")).Value = "new value";
((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/
Application_Data/Application_Info[@AI_TYPE='ETS_ADVERTISER']/Ai_Item/
@NAME")).Value = "new value";
xdoc.Save(fileName);
}
}
What this code does is it reads all .xml files in a directory, XML
files like the 2 examples here: http://www.keepitsimplekid.com/xml
it then takes and Replaces Untitled Ad twoards the top of the xml doc
with the text New Value. It also replaces the ETS ADVERTISER name,
for example REGIONAL CANCER CENTER, or LEAF GUARD OF LAKE ERIE with
the text new value.
Here is what I want to do. I will delete the line of code that
replaces the ETS ADVERTISER name with New Value, I want to keep the
line of code near the top that replaces the words Untitled Ad.
Instead of replacing Untitled Ad with new value, I want to replace it
with the value that is ETS ADVERTISER name, so Untitled Ad would be
replaced with LEAF GUARD OF LAKE ERE, or, REGINAL CANCER CENTER
How do I replace / fix this line of code to do that?
((XmlAttribute)xdoc.SelectSingleNode("/XMD-entity/Meta/@NAME")).Value
= "new value";
so I don't want it to = the text new value, I want it to = whatever
the ETS ADVERTISER name actually is.