-1

I have a scenario where I have an xml content and I need to get the version number from that file. For example below is the text.

<testing Version1 = "1.1" Version2 = "1.3">
<name> Example </Name>
<Description>sample description</Description>
</testing>

I need the Version2 value i.e., 1.3. Is it possible to get it by using Regex?

Thanks in Advance,

Anish
  • 219
  • 2
  • 12

1 Answers1

2

You can do it without a regular expression - example:

var xml = @"<testing Version1 = ""1.1"" Version2 = ""1.3"">
<Name> Example </Name>
<Description>sample description</Description>
</testing>";

string version2 = XElement.Parse(xml).Attribute("Version2").Value;
Rui Jarimba
  • 11,166
  • 11
  • 56
  • 86