How to convert List to xml document in c#
I would like to convert the List to a xml document in c#.
My code is as follows:
List<string> BugWSResponseList1 = new List<string>();
Logger.Write("\n\n" + DateTime.Now + " : " + " : START : Creation of a set
of Bugs via bug.Add API");
BugWSResponseList1 =
CreateBugs(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile);
Logger.Write("\n\n" + DateTime.Now + " : " + " : END : Creation of a set
of Bugs via bug.Add API");
I have been trying to convert the list response to string and then tried
to convert it in xml document but when i parse it then it shows that there
are more than one root elements in the xml.
The format of xml is as follows:
<Bug>
<family>ESG</family>
<product>Dr.Watson</product>
<version>Xpress API</version>
<productarea>1</productarea>
<subarea></subarea>
<qe>sdawar</qe>
<duplicateId></duplicateId>
</Bug>
<Bug>
<family>TEST22</family>
<product>Dr.Watson</product>
<version>Xpress API</version>
<productarea>1</productarea>
<subarea></subarea>
<qe>sdawar</qe>
<duplicateId></duplicateId>
</Bug>
Please note that it has two different nodes in the xml. What i am doing so
far is converting List BugWSResponseList1 to a string and then loading it
as xml.here is the code i am doing:
XmlDocument xd = new XmlDocument();
string s = string.Join(",", BugWSResponseList2);
xd.LoadXml(s);
But when i am doing it it says that there are more than one root element
in the xml.
I would like to convert the List BugWSResponseList1 to an xml document as
i need to parse it further for my code execution. Any help would be
appreciated. Thanks
No comments:
Post a Comment