using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"Level>(\d+)<\/tank";
string input = @"This XML file does not appear to have any style information associated with it. The document tree is shown below.
<seqSmartbox xmlns=""http://tecson.dev.oilview.de/gateway/xsd"" xmlns:xsi=""http://www.w3.org/2000/10/XMLSchema-instance"" xsi:schemaLocation=""http://tecson.dev.oilview.de/gateway/xsd/smartbox.xsd"">
<seqHeader>
<indication>Manuelle Abfrage</indication>
<authCode>03B41236A899</authCode>
<devOperator/>
<devLocation/>
<devID>2-852</devID>
<devVersion>V6.02</devVersion>
</seqHeader>
<seqData>
<seqTanks>
<tankNumber>1</tankNumber>
<tankName>Heizöl</tankName>
<seqTankLevel>
<tankLevel>490</tankLevel>
<tankUnit>L</tankUnit>
</seqTankLevel>
<tankPercent>5</tankPercent>
<seqTankSize>
<tankSize>10000</tankSize>
<tankUnit>L</tankUnit>
</seqTankSize>
<seqTankClear>
<tankClearance>9010</tankClearance>
<tankUnit>L</tankUnit>
</seqTankClear>
</seqTanks>
</seqData>
<seqPara>
<para1>30</para1>
<para2>15</para2>
<para4>0</para4>
<para5>5</para5>
<para9>0</para9>
</seqPara>
</seqSmartbox>";
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