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 :
HTML / XML
001
002
005HTML / XML
?-?-?
value="001">RZ
value="002">TH
value="003">SCHTML / XML
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 9, 2011, 11:32 PM EDT
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.