Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Text.RegularExpressions;
- namespace _10.ExtractXML
- {
- class Program
- {
- static void Main(string[] args)
- {
- string firstFileName = "../../mytemp01.txt";//the dir of the .cs file
- ReadFile(firstFileName);
- }
- private static void ReadFile(string firstFileName)
- {
- using (StreamReader sourceFile = new StreamReader(firstFileName))
- {
- string line = sourceFile.ReadLine();
- while (line != null)
- {
- string pattern = ">[^<]*</";
- string edited;
- int length;
- foreach (Match match in Regex.Matches(line, pattern))
- {
- edited = match.Value.ToString();
- length = edited.Length;
- edited = edited.Remove(length - 2, 2); //remove </
- edited = edited.Remove(0, 1); //remove >
- if (edited != null)
- {
- Console.WriteLine(edited);
- }
- }
- line = sourceFile.ReadLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement