need to get a number from an xml file using Regex [duplicate]









up vote
-1
down vote

favorite













This question already has an answer here:



  • Regex to extract attribute value

    2 answers



  • Read XML Attribute using XmlDocument

    7 answers



  • Getting attribute value of an XML Document using C#

    6 answers



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,










share|improve this question













marked as duplicate by CodeCaster c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 9 at 13:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Why not use XDocument?
    – cactuaroid
    Nov 9 at 12:56










  • See: stackoverflow.com/questions/933687/…
    – NoChance
    Nov 9 at 13:04














up vote
-1
down vote

favorite













This question already has an answer here:



  • Regex to extract attribute value

    2 answers



  • Read XML Attribute using XmlDocument

    7 answers



  • Getting attribute value of an XML Document using C#

    6 answers



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,










share|improve this question













marked as duplicate by CodeCaster c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 9 at 13:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Why not use XDocument?
    – cactuaroid
    Nov 9 at 12:56










  • See: stackoverflow.com/questions/933687/…
    – NoChance
    Nov 9 at 13:04












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:



  • Regex to extract attribute value

    2 answers



  • Read XML Attribute using XmlDocument

    7 answers



  • Getting attribute value of an XML Document using C#

    6 answers



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,










share|improve this question














This question already has an answer here:



  • Regex to extract attribute value

    2 answers



  • Read XML Attribute using XmlDocument

    7 answers



  • Getting attribute value of an XML Document using C#

    6 answers



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,





This question already has an answer here:



  • Regex to extract attribute value

    2 answers



  • Read XML Attribute using XmlDocument

    7 answers



  • Getting attribute value of an XML Document using C#

    6 answers







c#






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 12:53









Anish

565




565




marked as duplicate by CodeCaster c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 9 at 13:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by CodeCaster c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 9 at 13:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2




    Why not use XDocument?
    – cactuaroid
    Nov 9 at 12:56










  • See: stackoverflow.com/questions/933687/…
    – NoChance
    Nov 9 at 13:04












  • 2




    Why not use XDocument?
    – cactuaroid
    Nov 9 at 12:56










  • See: stackoverflow.com/questions/933687/…
    – NoChance
    Nov 9 at 13:04







2




2




Why not use XDocument?
– cactuaroid
Nov 9 at 12:56




Why not use XDocument?
– cactuaroid
Nov 9 at 12:56












See: stackoverflow.com/questions/933687/…
– NoChance
Nov 9 at 13:04




See: stackoverflow.com/questions/933687/…
– NoChance
Nov 9 at 13:04












1 Answer
1






active

oldest

votes

















up vote
2
down vote













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;





share|improve this answer



























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    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;





    share|improve this answer
























      up vote
      2
      down vote













      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;





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        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;





        share|improve this answer












        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;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 12:59









        Rui Jarimba

        6,93462958




        6,93462958













            Popular posts from this blog

            How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

            Syphilis

            Darth Vader #20