string replacetext="<td title=\"Compatible versions: a29d.3efe\" class=\"critical hastooltip\">"
this is string type variable which holds a value from XML document. My scenario is as such:
this string is being used to match the tag element and extract it's value. Problem is that the part Compatible Version:a29d.3efe is not constant and so I can't hardcode it to give desired result,that is my required tag. I wanted to have a regular expression or something similar solution where it can recognise any data, mostly alphanumberic characters with special symbols, and then I should be able to extract it's value. How can i do it?
This is piece fo code that I can share:
if (MFMStatusUrlSettings != null)
{
string replaceText = "<td title=\"Compatible versions: a29d.fe3e\" class=\"critical hastooltip\">";
string toGetMatch = MFMStatusUrlSettings.Replace(replaceText, "<td>");
MatchCollection Collection = Regex.Matches(toGetMatch, @"<td>(?<Value>.*?)</td>");
Firmware_CRC = GetStrValueBetweenTags(Collection[5].ToString(), "<td>", "</td>");
deviceInfo.Description = Firmware_CRC;
}
So, for replaceText I wanted to get the tag data irrespective of whatever is there in Compatible Version section
XML documents:For reference
Document 1:
<Status>
<Summary>
<Uptime>05:14:38</Uptime>
<FastWD>00:02:50</FastWD>
<SlowWD>18:45:22</SlowWD>
<Configuration_Download>Success</Configuration_Download>
<Firmware_CRC title="Compatible versions: a29d.4adc" class="critical hastooltip">a29d.3db8</Firmware_CRC>
<Core_Version>19.6</Core_Version>
<App_Version>23.4</App_Version>
<CPLD_Version>4BF44D51</CPLD_Version>
</Summary>
<Detectors>
<state>Operating</state>
<detector>8 channel - Lane agile radar: Operating</detector>
<detector>2 channel - Wired light phase detector: Operating</detector>
<detector>Optical Light Phase Detector: Absent</detector>
<self_test>pass[00]</self_test>
<radar_error_counter>0</radar_error_counter>
</Detectors>
</Status>
Document 2:
<Status>
<Summary>
<Uptime>05:58:56</Uptime>
<FastWD>00:02:06</FastWD>
<SlowWD>18:01:04</SlowWD>
<Configuration_Download>Success</Configuration_Download>
<Firmware_CRC title="Compatible versions: a29d.fe3e" class="critical hastooltip">a29d.3db8</Firmware_CRC>
<Core_Version>19.6</Core_Version>
<App_Version>23.4</App_Version>
<CPLD_Version>4BF44D51</CPLD_Version>
</Summary>
<Detectors>
<state>Operating</state>
<detector>8 channel - Lane agile radar: Operating</detector>
<detector>2 channel - Wired light phase detector: Operating</detector>
<detector>Optical Light Phase Detector: Absent</detector>
<self_test>pass[00]</self_test>
<radar_error_counter>0</radar_error_counter>
</Detectors>
</Status>