locked
I have to convert xml node to lower case by regex in C# without replacing each node RRS feed

  • Question

  • User-1636183269 posted

    Hello All,

    I have to change below  XML to its node only in lower case. How can I do by Regex in C#?

    <MyXML><SomeNode>Hello World</SomeNode></MyXML>

    to

    <myxml><somenode>Hello World</somenode></myxml>

    Monday, September 25, 2017 5:42 AM

Answers

  • User-1636183269 posted

    I am able to fix this issue in C#

    string sampleXML = "<TestXML><ChildNode>Hello World</ChildNode></TestXML><TestXML><ChildNode>Hello World</ChildNode></TestXML><TestXML><ChildNode>Hello World</ChildNode></TestXML>";
    sampleXML = Regex.Replace(sampleXML, @"<(.|\n)*?>", m => m.Value.ToLower());

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 25, 2017 11:12 AM

All replies

  • User-1636183269 posted

    I am able to fix this issue in C#

    string sampleXML = "<TestXML><ChildNode>Hello World</ChildNode></TestXML><TestXML><ChildNode>Hello World</ChildNode></TestXML><TestXML><ChildNode>Hello World</ChildNode></TestXML>";
    sampleXML = Regex.Replace(sampleXML, @"<(.|\n)*?>", m => m.Value.ToLower());

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 25, 2017 11:12 AM
  • User-707554951 posted

    Hi Das.Sandeep,

    If you have solved the problem, please mark the post to let others know.

    Best regards

    Cathy

    Tuesday, September 26, 2017 3:30 AM