0

Input is of the format shown below :

<HiddenRowGroups>
    <HiddenGroup>
      <From>16</From>
      <To>17</To>
      <Level>0</Level>
      <GroupName>TABS</GroupName>
      <ItemTotalHeader>Total</ItemTotalHeader>
    </HiddenGroup>
    <HiddenGroup>
      <From>3</From>
      <To>3</To>
      <Level>0</Level>
      <GroupName>ABSCDXH</GroupName>
      <ItemTotalHeader>Total</ItemTotalHeader>
    </HiddenGroup>
  </HiddenRowGroups>

Desired Output : <HiddenRowGroups />

How to replace the regex which is in form of a string to <HiddenRowGroups /> . I tried replacing it via Regex.Replace method of C#.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
StackOverflowVeryHelpful
  • 2,347
  • 8
  • 34
  • 46
  • 1
    _What_ are you trying to accomplish? What are you trying to replace? What regex are you using? Why aren't you using one of the XML APIs to work with XML? – John Saunders Apr 02 '13 at 23:18
  • I am working on C# code. This xml is actually XAML grid which i serialize into string and save it into the database. As mentioned in the question above i have given both input and output(result) i want to achieve. Let me know if i answered your questions. – StackOverflowVeryHelpful Apr 02 '13 at 23:21
  • Do not do this with regex. Regex is completely unsuited to this task. Use XSLT. See http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags#1732454 – Jim Garrison Apr 02 '13 at 23:25
  • Hello Jim , I tried playing around with it but couldn't find an appropriate answer – StackOverflowVeryHelpful Apr 02 '13 at 23:47
  • Are you trying to remove all the elements inside of ``? – John Saunders Apr 03 '13 at 00:02
  • Yes correct. and i got the solution as well. Was testing it [\d\w\s\W\D]*<\/HiddenRowGroups> .Thanks for your time and help. – StackOverflowVeryHelpful Apr 03 '13 at 00:05

0 Answers0