Hi Sudar,
When you have multiple root elements and try to Load the xml string at that time you will get error as There are multiple root elements because the xml string is not valid.
So for that to make valid by adding a dummy root element. You need to enclose your <data> elements in a surrounding element as XML Documents can have only one root node.
Check this example. Now please take its reference and correct your code.
HTML
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
Namespaces
C#
using System.Xml;
using System.Text;
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
var xmlString = "<data><SessionDetails /><KAMName /><Date>5/15/2018</Date><CoachName>test test</CoachName><Course>Storyboarding</Course><Howarefeelingtoday /><Question1>1. Poor</Question1><Comments1>aa</Comments1><WhatscorewouldyougivethecompanyonKAM /><Question3>2. Average</Question3><Comments3>ss</Comments3><WhatscorewouldyougiveyourselfonKAM /><Question4>3. Good</Question4><Comments4>ddd</Comments4><Doesyourcurrentpropositionanswerthecustomerneeds /><Question5>4. Very Good</Question5><Comments5>fff</Comments5><Howwouldyourateyourcurrentincentiveschemeinhelpingyoudrivesales /><Question6>5. Excellent</Question6><Comments6>ggg</Comments6><HowhardiscurrentaccesstoNHScustomers /><Question7>6. N/A</Question7><Comments7>hhh</Comments7><Howwouldyourateyourpreparednesscomparedtoyourcompetitors /><Question8>1. Poor</Question8><Comments8>jjj</Comments8><Howwellisthecurrentcampaignworkingwithtargetcustomers /><Question9>2. Average</Question9><Comments9>kkk</Comments9><Doyoufeelpreparedforthenextcall /><Question2>3. Good</Question2><Comments2>lll</Comments2><DoyoufeelyourICQisbetterfollowingthisKAMClinic /><Question10>4. Very Good</Question10><Comments10>qqq</Comments10><CoachReview /><SessionNotes>dfgdfg vbvcbcv dgdfgdfg</SessionNotes><__CurrentAction>4</__CurrentAction></data>";
xmlString += "<data><SessionDetails /><KAMName /><Date>5/16/2018</Date><CoachName>test1 test1</CoachName><Course>Storyboarding</Course><Howarefeelingtoday /><Question1>1. Poor</Question1><Comments1>aa</Comments1><WhatscorewouldyougivethecompanyonKAM /><Question3>2. Average</Question3><Comments3>ss</Comments3><WhatscorewouldyougiveyourselfonKAM /><Question4>3. Good</Question4><Comments4>ddd</Comments4><Doesyourcurrentpropositionanswerthecustomerneeds /><Question5>4. Very Good</Question5><Comments5>fff</Comments5><Howwouldyourateyourcurrentincentiveschemeinhelpingyoudrivesales /><Question6>5. Excellent</Question6><Comments6>ggg</Comments6><HowhardiscurrentaccesstoNHScustomers /><Question7>6. N/A</Question7><Comments7>hhh</Comments7><Howwouldyourateyourpreparednesscomparedtoyourcompetitors /><Question8>1. Poor</Question8><Comments8>jjj</Comments8><Howwellisthecurrentcampaignworkingwithtargetcustomers /><Question9>2. Average</Question9><Comments9>kkk</Comments9><Doyoufeelpreparedforthenextcall /><Question2>3. Good</Question2><Comments2>lll</Comments2><DoyoufeelyourICQisbetterfollowingthisKAMClinic /><Question10>4. Very Good</Question10><Comments10>qqq</Comments10><CoachReview /><SessionNotes>dfgdfg vbvcbcv dgdfgdfg</SessionNotes><__CurrentAction>4</__CurrentAction></data>";
XmlDocument doc = new XmlDocument();
// Adding dummy root element.
doc.LoadXml("<root>" + xmlString + "</root>");
XmlNodeList nodes = doc.DocumentElement.SelectNodes("//data");
StringBuilder yourString = new StringBuilder();
foreach (XmlNode node in nodes)
{
yourString.Append("Date:" + node["Date"].InnerText + "<br />");
yourString.Append("CoachName:" + node["CoachName"].InnerText + ",");
}
PlaceHolder1.Controls.Add(new LiteralControl(yourString.ToString()));
}
Screenshot
