Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i pass List<string> response as an xml document using c#
    primarykey
    data
    text
    <p>I would like to pass an List response as an xml document and want to load it as xml. Currently i am performing it using this code :</p> <pre><code>List&lt;string&gt; BugWSResponseList1 = new List&lt;string&gt;(); BugWSResponseList1 = CreateBugs(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile, newValue); XmlDocument xd = new XmlDocument(); //string s = string.Join(",", BugWSResponseList2); //xd.LoadXml(s); string s = "&lt;Bugs&gt;" + string.Join(",", BugWSResponseList1) + "&lt;/Bugs&gt;"; xd.LoadXml(s); //Dictionary Creation for Benchmark API XmlDocument ResponseNode_bugs = null; ResponseNode_bugs = new DrWatsonCore().LoadXMLDocument(s); </code></pre> <p>I would like to avoid to convert the <code>List&lt;string&gt;</code> response to string first and then loading it as xml. Please suggest how can i achieve that.</p> <p>Please find the detail of my <code>LoadXMLDocument</code> function as follows:</p> <pre><code>public XmlDocument LoadXMLDocument(string XMLData) { XmlDocument doc = new XmlDocument(); try { doc.LoadXml(XMLData); } catch (Exception ex) { Logger.Write("\n\n" + DateTime.Now + " : " + "LoadXMLDocument : SEVERE ERROR : Failed to create XMLDocument from given string : \n\n"); Logger.Write("\n\n" + DateTime.Now + " : " + "Exception : : \n\n" + ex.Message); Logger.Write("\n\n" + DateTime.Now + " : " + "Given String : : \n\n"); if (DrWatsonHome.doVerboseLogging) { Logger.Write(XMLData); } else { string Response = XMLData; Logger.Write("\n\n" + DateTime.Now + " : " + "Response Length : " + Response.Length + " characters."); int ResponseLengthToPrint = DrWatsonHome.VerboseLogging_Length_Chars &lt; Response.Length ? DrWatsonHome.VerboseLogging_Length_Chars : Response.Length; Logger.Write("\n\n" + DateTime.Now + " : " + "Response : " + Response.Substring(0, ResponseLengthToPrint) + " ..."); } } finally { } return doc; } </code></pre> <p>Can i achieve it after making some modifications in it.Please suggest.</p> <p>I am using List now and my function is as follows:</p> <pre><code>List&lt;XElement&gt; Sairam(string FilePath, string Timestamp) { List&lt;XElement&gt; WSResponse = new List&lt;XElement&gt;(); XmlDocument XDoc = new DrWatsonCore().LoadXMLFromFile(FilePath); XmlNode BugListNode = XDoc.SelectSingleNode("/DrWatson/Bugs"); List&lt;Bug&gt; BugList = new DrWatsonCore().GetBugList(BugListNode); List&lt;Thread&gt; BugFtecherThreadList = new List&lt;Thread&gt;(); foreach (Bug bug in BugList) { bug.FoundInBuild = Timestamp; string URL = new DrWatsonCore().CreateWXURL(EXPRESS_API_METHOD.bug_add, bug, REST_EndPoint, AppGUID, new WatsonUser(Username_Watson, Password_Watson)); string Response = string.Empty; object URLobj = (object) URL; Response = CreateBug(URLobj); // WSResponse.Add(Response); } return WSResponse; } </code></pre> <p>I would like to get the WSResponse as the final response of teh program but i am unable to fetch it. Please suggest so how can i get the response of this program from this function.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload