Hello,
i try to read a XML file in C# but everytime i got the Error "Data at the root level is invalid. Line 1, position 1."
I dont know how to fix it. Can anyone help me?
This is my code:
if ((filename.ToLower() == "lead.xml" || filename.ToLower() == "lead.xml.xml") && ent.Attributes.Contains("body"))//aktualisieren { byte[] data = Convert.FromBase64String(ent.Attributes["body"].ToString()); string xml = Encoding.UTF8.GetString(data); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); doc.PreserveWhitespace = false; XmlNode root = doc.DocumentElement; tracingService.Trace("läuft2"); foreach (XmlNode node in root) { if (node.Name == "recipient") {...
*This post is locked for comments
Hi All,
Can this be applied for Al code which connects Business Central ?
Yes!
It works B-)
Thank you!
Hi.
It may be UTF BOM mark. More solutions here: stackoverflow.com/.../xml-loaddata-data-at-the-root-level-is-invalid-line-1-position-1
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156