I have a XML file which is like this;
<?xml version="1.0" encoding="utf-8"?>
<Data>
<StringMaps>
<Menu>
<String Target="BtnFile" Link="Файл" />
<String Target="BtnOpen" Link="Открыто" />
<String Target="BtnSave" Link="Сохранить" />
<String Target="BtnClose" Link="Закрыть" />
</Menu>
</StringMaps>
</Data>
and I load document using XmlDocument
.
And then I have two XmlNodeList
which are targetAttrs
and linkAttrs
.
I'm using this code to get the values;
var targetAttrs = xmldoc1.SelectNodes("/Data/StringMaps/Menu/String/@Target");
var linkAttrs = xmldoc1.SelectNodes("/Data/StringMaps/Menu/String/@Link");
foreach (XmlNode temptarget in targetAttrs)
{
foreach (XmlNode templink in linkAttrs)
{
MessageBox.Show(string.Format("{0} = {1}", temptarget.Value, templink.Value));
}
}
I'm trying to get values as key-value pairs like these;
BtnFile = Файл
BtnOpen = Открыто
BtnSave = Сохранить
BtnClose = Закрыть
But I get these;
BtnFile = Файл
BtnFile = Открыто
BtnFile = Сохранить
BtnFile = Закрыть
BtnOpen = Файл
BtnOpen = Открыто
BtnOpen = Сохранить
BtnOpen = Закрыть
BtnSave = Файл
BtnSave = Открыто
BtnSave = Сохранить
BtnSave = Закрыть
BtnClose = Файл
BtnClose = Открыто
BtnClose = Сохранить
BtnClose = Закрыть
If someone writes the code and explains the exact logic, i would be very appreciated.