I have two XML file. One is given by the user say Source.xml and other is given by the application it self means load from the main project.
Like,
Source.xml :
001
002
005
Mapping.xml :
?-?-?
value="001">RZ
value="002">TH
value="003">SC
And resultant output I want is :
RZ
TH
?-?-?
It means I just want to map two xml file and want the output as shown above.
So, please help me to do so. I am new to asp.net.

Posted Jun 10, 2011, 3:32 AM
string input = " 001 002 005";
string mappinginput = "";
System.Xml.XmlDocument source = new System.Xml.XmlDocument();
source.LoadXml(input);
System.Xml.XmlDocument mapping = new System.Xml.XmlDocument();
mapping.LoadXml(mappinginput);
string output = "";
foreach(System.Xml.XmlNode node in source.SelectNodes("/input/data"))
{
System.Xml.XmlNode childNode = mapping.SelectSingleNode("//map/input[@value='" + node.InnerText +"']");
if (childNode != null)
{
if (node.InnerText == childNode.Attributes["value"].InnerText)
{
output += "" + childNode.InnerText + "";
}
}
else
{
output += "" + mapping.SelectSingleNode("/map/default").InnerText + "";
}
}
output = "";
MessageBox.Show(output);
The output will be like....
Hope this helps you.