0
Good staff
I have this code:
public static string filePath = Path.GetTempPath();
public static void ImportFile(string path, string fileToRead)
{
if (!File.Exists(path))
File.Create(path).Close();
using (XmlTextWriter writer = new XmlTextWriter(path, null))
{
string[] lines = System.IO.File.ReadAllLines(fileToRead);
string cabecalho = lines.Where(x => x.Contains("#")).FirstOrDefault();
cabecalho = cabecalho.Substring(1);
string[] headers = cabecalho.Split('|').Select(x => x.Trim().TrimEnd().TrimStart()).ToArray();
string[] values = lines.Where(x => !x.Contains("#")).ToArray();
writer.WriteStartDocument();
writer.Formatting = System.Xml.Formatting.Indented;
writer.WriteStartElement("bloodonors");
Array.ForEach(values, (j) =>
{
string value = j;
value = value.Substring(1);
string[] v = value.Split('|').Select(x => x.Trim().TrimEnd().TrimStart()).ToArray();
writer.WriteStartElement("donor");
for (int i = 0; i < headers.Length; i++)
{
writer.WriteElementString(headers[i], v[i]);
}
writer.WriteEndElement();
});
writer.WriteFullEndElement();
}
}
I would like to know how I can migrate to a web service the TXT file used to download XML?
Regards
You want to save the generated xml to the server?
– Leandro Angelo
I want to upload a TXT file to a Webservice.
– Henrique Q.
Post for another service?
– Leandro Angelo
Or you want to create a webservice that returns this result in xml format?
– Leandro Angelo