HI
IM A STUDENT THAT HAVE AN EMERGENCY PROJECT THAT SHOULD CONVERT STRING INTO 5000 XML FILE AND HAVE THIS CODE AND NEED TO HELP FOR COMPLETE THIS MISSION
THANK YOU VERY MUCH <3
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApplication35.Model;
namespace WindowsFormsApplication35
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
string dc = "";
string dwc = "";
string foxml = "";
// Record 1
Objects o = new Objects();
o.subject = "GUI";
o.title = "this is sample record1";
dc = CreateDCRecord(o);
dwc = CreateDWCRecord(o);
foxml = CreateFOXMLRecord(dwc,dc);
WriteAllFile(foxml,"1");
//Record 2
Objects o2 = new Objects();
o2.subject = "GUI";
o2.title = "this is sample record1";
dc = CreateDCRecord(o2);
dwc = CreateDWCRecord(o2);
foxml = CreateFOXMLRecord(dwc, dc);
WriteAllFile(foxml, "2");
//Record 3
Objects o3 = new Objects();
o3.subject = "GUI";
o3.title = "this is sample record1";
dc = CreateDCRecord(o3);
dwc = CreateDWCRecord(o3);
foxml = CreateFOXMLRecord(dwc, dc);
WriteAllFile(foxml, "3");
}
private void WriteAllFile(string FileContent, string FileName)
{
System.IO.File.WriteAllText(@"C:\Temp\FOXML"+FileName+".xml", FileContent);
}
private static string CreateDCRecord(Objects o)
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.Append("<Items>");
sb.Append("<item>");
sb.Append("<title>" + o.title + "</title>");
sb.Append("<subject>" + o.subject + "</subject>");
sb.Append("</item>");
sb.Append("</Items>");
return sb.ToString();
}
private static string CreateDWCRecord(Objects o)
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.Append("<Items>");
sb.Append("<item>");
sb.Append("<title>" + o.title + "</title>");
sb.Append("<subject>" + o.subject + "</subject>");
sb.Append("</item>");
sb.Append("</Items>");
return sb.ToString();
}
private static string CreateFOXMLRecord(string dwc, string dc)
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.Append("<Items>");
sb.Append("<item>");
sb.Append("<dwc>" + dwc + "</dwc>");
sb.Append("<dc>" + dc + "</dc>");
sb.Append("</item>");
sb.Append("</Items>");
return sb.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}