Hi All,
I have this piece of code below:
_____________________________________
XmlDocument doc = new XmlDocument();
string sFileName = @"C:\temp\testFile.xml";
doc.Load(sFileName);
XmlNodeList textNodes = doc.SelectNodes("//fbkMetaValueT");
foreach (DataRow currentRow in ds.Tables[0].Rows)
{
string toTranslate = currentRow[3].ToString().Trim();
for (int columnCounter = 4; columnCounter < ds.Tables[0].Columns.Count; columnCounter++)
{
string countryCode = ds.Tables[0].Columns[columnCounter].ColumnName;
string translation = currentRow[columnCounter].ToString().Trim();
foreach (XmlNode currentNode in textNodes)
{
string longText = currentNode.Attributes[0].Value.Trim();
string locale = currentNode.Attributes[2].Value.Trim();
longText.Replace("'", "");
translation.Replace("'", "");
toTranslate.Replace("'", "");
if ((longText == toTranslate) && (locale == countryCode))
{
currentNode.Attributes[0].Value = translation;
}
}
}
}
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create("c:\\temp\\test.xml",settings))
{
doc.WriteContentTo(writer);
writer.Flush();
writer.Close();
}
________________________________________________
Esentially what I'm doing is scanning through a dataset and updating a Node Value within an existing XML file (which I've read in fine) - however I only want to update certain nodes where that node value matches a value in my dataset. This works fine - with all strings apart from those that contain an apostrophe character. The line that does the matching is:
if ((longText == toTranslate) && (locale == countryCode))
The longText string is compared to the toTranslate string. These are the two strings that contain the apostrophe characters. I know the value I want to update is also always located at [0] on the Attribute list
I've done some debugging and these values look exactly the same.
Can anyone help me on this? It's pretty urgent so any urgent help would be greatly appreciated
Many Thanks,
Dan