using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<id>(.+?)<\/id>|<name>(.+?)<\/name>|<time>(.+?)<\/time>|<line>(.+?)<\/line>|<timeMin>(.+?)<\/timeMin>";
string input = @"<?xml version=""1.0"" encoding=""utf-8""?>
<ArrayOfPolling xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<Polling>
<id>1494</id>
<name>Street xyz</name>
<time>14.08</time>
<line>AB2</line>
<timeMin>5</timeMin>
</Polling>
<Polling>
<id>1494</id>
<name>Street xyz</name>
<time>14.10</time>
<line>140</line>
<timeMin>7</timeMin>
</Polling>
<Polling>
<id>1494</id>
<name>Street xyz</name>
<time>14.12</time>
<line>AB2</line>
<timeMin>9</timeMin>
</Polling>
<Polling>
<id>1494</id>
<name>Street xyz</name>
<time>14.15</time>
<line>140</line>
<timeMin>12</timeMin>
</Polling>
</ArrayOfPolling>";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx