Beta 1.0.0.4
1. BillsController - > Endpoints 2. NoticeboardController - > Endpoints 3. ReportsController - > EndPoints 4.TransactionController -> Endpoints 5. UsersController - > Endpoints
This commit is contained in:
@@ -145,6 +145,39 @@ namespace APISocietyToolBox.Functions
|
||||
}
|
||||
|
||||
|
||||
public static string ConvertJsonArrayToXmlR1(string jsonArray, string rootElementName, string itemElementName)
|
||||
{
|
||||
// Parse JSON array to JArray
|
||||
JArray array = JArray.Parse(jsonArray);
|
||||
|
||||
// Create the root XML element with the user-defined name
|
||||
XElement rootElement = new XElement(rootElementName);
|
||||
|
||||
// Convert each JSON object in the array to XML elements
|
||||
foreach (JObject item in array)
|
||||
{
|
||||
// Create an item element for each item in the array
|
||||
XElement itemElement = new XElement(itemElementName);
|
||||
|
||||
// Convert JSON properties to XML elements with values for each item
|
||||
foreach (var property in item.Properties())
|
||||
{
|
||||
// Add property value to XML
|
||||
itemElement.Add(new XElement(property.Name, property.Value.ToString()));
|
||||
}
|
||||
|
||||
// Add the item element to the root element
|
||||
rootElement.Add(itemElement);
|
||||
}
|
||||
|
||||
// Convert the XElement to an XML string
|
||||
string xmlString = rootElement.ToString();
|
||||
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper method to recursively convert JToken to XML
|
||||
private static XElement ConvertJTokenToXml(JToken token, XElement parentElement)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user