using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<RawData>55014B467FFF0C10BEFF00+<\/RawData>\n\n<PrimaryValue>(\d+.\d+)";
string input = @"<?xml version=""1.0"" encoding=""UTF-8""?>
-<Devices-Detail-Response xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.embeddeddatasystems.com/schema/owserver"">
<PollCount>71</PollCount>
<DevicesConnected>2</DevicesConnected>
<LoopTime>2.048</LoopTime>
<DevicesConnectedChannel1>2</DevicesConnectedChannel1>
<DevicesConnectedChannel2>0</DevicesConnectedChannel2>
<DevicesConnectedChannel3>0</DevicesConnectedChannel3>
<DataErrorsChannel1>0</DataErrorsChannel1>
<DataErrorsChannel2>0</DataErrorsChannel2>
<DataErrorsChannel3>0</DataErrorsChannel3>
<VoltageChannel1>4.81</VoltageChannel1>
<VoltageChannel2>4.81</VoltageChannel2>
<VoltageChannel3>4.80</VoltageChannel3>
<VoltagePower>5.05</VoltagePower>
<DeviceName>OWServer_v2-Enet</DeviceName>
<HostName>EDSOWSERVER2</HostName>
<MACAddress>00:04:A3:BE:A9:F2</MACAddress>
<DateTime>2017-03-10 23:18:40</DateTime>
-<owd_DS18B20 Description=""Programmable resolution thermometer"">
<Name>DS18B20</Name>
<Family>28</Family>
<ROMId>690516B3FC14FF28</ROMId>
<Health>7</Health>
<Channel>1</Channel>
<RawData>54014B467FFF0C10FDFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</RawData>
<PrimaryValue>21.2500 Deg C</PrimaryValue>
<Temperature Units=""Centigrade"">21.2500</Temperature>
<UserByte1 Writable=""True"">75</UserByte1>
<UserByte2 Writable=""True"">70</UserByte2>
<Resolution>12</Resolution>
<PowerSource>255</PowerSource>
</owd_DS18B20>
-<owd_DS18B20 Description=""Programmable resolution thermometer"">
<Name>DS18B20</Name>
<Family>28</Family>
<ROMId>020316B4A6C3FF28</ROMId>
<Health>7</Health>
<Channel>1</Channel>
<RawData>55014B467FFF0C10BEFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</RawData>
<PrimaryValue>21.3125 Deg C</PrimaryValue>
<Temperature Units=""Centigrade"">21.3125</Temperature>
<UserByte1 Writable=""True"">75</UserByte1>
<UserByte2 Writable=""True"">70</UserByte2>
<Resolution>12</Resolution>
<PowerSource>255</PowerSource>
</owd_DS18B20>
</Devices-Detail-Response>";
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