Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- class ExtractFromXML
- {
- static void Main()
- {
- string xmlPath = @"..\..\Test.xml";
- ExtractText(xmlPath);
- }
- static void ExtractText(string path)
- {
- StreamReader reader = new StreamReader(path);
- StringBuilder textToExtract = new StringBuilder();
- using (reader)
- {
- string line = reader.ReadLine();
- while (line != null)
- {
- line = line.Trim();
- for (int i = 0; i < line.Length; i++)
- {
- // append every char after '>' till char is equal to '<'
- if (line[i] == '>' && i + 1 < line.Length)
- {
- i++;
- while (line[i] != '<')
- {
- textToExtract.Append(line[i]);
- i++;
- }
- Console.WriteLine(textToExtract.ToString().Trim());
- textToExtract.Clear();
- }
- }
- line = reader.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement