HoneyGulati
5 months agoNew Contributor III
Can we convert text file to xml via Business Rule
Hi,
Can someone suggest if the text file can be converted into xml file via business rule?
An XML file is already a text file but in a particular format. It can be done through business rules - select the source file, process it and save it with an XML extension. You will need to know the XML structure. Then you can use XmlDocument to create the file. Here is a quick sample for creating the XML file:
Imports System.Xml ' Create an XML document Dim xmlDoc As New XmlDocument() ' Create the declaration Dim declaration As XmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", Nothing) xmlDoc.AppendChild(declaration) ' Create the root element Dim myReport As XmlElement = xmlDoc.CreateElement("OECD") xmlDoc.AppendChild(myReport) ' Add attributes to the root element myReport.SetAttribute("version", "2.0") ' Create and append the ReportingEntity element Dim reportingEntity As XmlElement = xmlDoc.CreateElement("ReportingEntity") myReport.AppendChild(reportingEntity) Dim fileFullName As String = "C:\Temp\MyFile.xml" ' Save the XML document to a file xmlDoc.Save(fileFullName)