/// <summary>
/// Methord used to create Xml By Passing the Object
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static XmlDocument ObjectTOXml(object obj)
{
string xmlStr;
string startBlock;
string endBlock;
startBlock = "{'root':";
endBlock = "}";
xmlStr = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
//Adding A common Parent Node to the json String
xmlStr = startBlock + xmlStr + endBlock;
//Converting the json String to Xml
XmlDocument xDoc = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(xmlStr);
return xDoc;
}
/// Methord used to create Xml By Passing the Object
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static XmlDocument ObjectTOXml(object obj)
{
string xmlStr;
string startBlock;
string endBlock;
startBlock = "{'root':";
endBlock = "}";
xmlStr = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
//Adding A common Parent Node to the json String
xmlStr = startBlock + xmlStr + endBlock;
//Converting the json String to Xml
XmlDocument xDoc = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(xmlStr);
return xDoc;
}
No comments:
Post a Comment