Replace all first letter of xml tag into capital letter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dillipkumar
    New Member
    • Mar 2008
    • 41

    Replace all first letter of xml tag into capital letter

    Hi All,

    I am hiving a file having data:

    <name>InDia</name>

    I want to change like:

    <ST_Name>InDi a</ST_Name>

    I am able to change the 1st tag but not able to change the end tag as my expectaion.

    i am using this script:
    $string =~ s/(\w+)/ST_\u$1/;


    Can any body help for the above issue.

    Thanks,
    dks
  • Dominik Przybys
    New Member
    • Jul 2011
    • 8

    #2
    try:
    $string =~ s/(\w+)/ST_\u$1/g;

    Comment

    • toolic
      Recognized Expert New Member
      • Sep 2009
      • 70

      #3
      It is best to modify XML files using an XML parser. I recommend XML::Twig. The set_tag method is used to globally modify start and end tags.

      Comment

      • dillipkumar
        New Member
        • Mar 2008
        • 41

        #4
        Thanks for your help. But the o/p is not showing properly.

        O/P:
        <ST_Name>ST_InD ia</ST_Name>

        ~DK

        Comment

        Working...