Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Security;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Linq;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string file = @"d:\medias\desktop\listwordspt.txt";
- string[] lines = File.ReadAllText(file).Split(new char[] { '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
- var xdoc = new XDocument(new XElement("Words"));
- for (int i = 0; i < lines.Length; i += 3)
- {
- string wordBr = WebUtility.HtmlDecode(lines[i]).Trim();
- string wordPt = WebUtility.HtmlDecode(lines[i + 1]).Trim();
- string[] wordsPt = wordPt.Split(',');
- string singlePtWord = string.Empty;
- //System.Web.HttpUtils
- for (int j = 0; j < wordsPt.Length; j++)
- {
- wordsPt[j] = wordsPt[j].Trim();
- if (wordsPt[j] != wordBr)
- {
- singlePtWord = wordsPt[j];
- break;
- }
- }
- // TODO: loiro/a, vendedor > vendedora, Tudo bem?
- //string wordEn = Uri.UnescapeDataString(lines[i+2]);
- //wordBr = WebUtility.HtmlDecode(wordBr);
- //singlePtWord = WebUtility.HtmlDecode(singlePtWord);
- //wordBr = WebUtility.HtmlDecode(wordBr);
- //singlePtWord = WebUtility.HtmlDecode(singlePtWord);
- // # Will escape chars like: "<" => "<"
- //wordBr = SecurityElement.Escape(wordBr);
- //singlePtWord = SecurityElement.Escape(singlePtWord);
- var xElement = new XElement("Word");
- xElement.Add(new XAttribute("br", wordBr));
- xElement.Add(new XAttribute("pt", singlePtWord));
- //xdoc.Add(new XElement("Word",
- // new XAttribute("br", wordBr),
- // new XAttribute("pt", singlePtWord)
- // ));
- xdoc.Element("Words").Add(xElement);
- }
- xdoc.Save(@"d:\medias\desktop\listwordspt.xml");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement