Skip to content

Commit

Permalink
fixed XMLToObject service to return correct XML part
Browse files Browse the repository at this point in the history
  • Loading branch information
saivineeth100 committed Nov 20, 2023
1 parent 91f7395 commit 46bcb19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/TallyConnector/Services/XMLToObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public static T GetObjfromXml<T>(string Xml, XmlAttributeOverrides? attrOverride
IEnumerable<string> values;
if (!string.IsNullOrEmpty(RootElement))
{
RootElement = $"<{RootElement} ";
var beforeLines = Splittedstrings.Take(StartIndex).Reverse();
int linenum = StartIndex;
foreach (string line in beforeLines)
Expand Down
22 changes: 22 additions & 0 deletions src/Tests/Services/XMLToObjectServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TallyConnector.Core.Models;

namespace Tests.Services;
public class XMLToObjectServiceTests
{
[Test]
public void TestXMLToObject()
{
string xml = File.ReadAllText("C:\\Users\\talla\\Downloads\\Untitled-1.xml");
XmlAttributeOverrides XMLAttributeOverrides = new();
XmlAttributes attrs = new();
attrs.XmlElements.Add(new("VOUCHER"));
XMLAttributeOverrides.Add(typeof(Colllection<Voucher>), "Objects", attrs);
var voucher = XMLToObject.GetObjfromXml<Envelope<Voucher>>(xml, XMLAttributeOverrides);
}
}

0 comments on commit 46bcb19

Please sign in to comment.