in reply to Search and Replace for XML

Could you clarify the question a bit.

Do you want the content of b.txt to be entered into the xml of a.txt, under what conditions?

To delete the content of the <!..> tag

$line=~s/<![^>]*>/<!>/;

Replies are listed 'Best First'.
Re^2: Search and Replace for XML
by GrandFather (Saint) on Apr 28, 2008 at 21:50 UTC

    Consider:

    my $line = '<!-- Gone > Not gone -->'; $line =~s/<![^>]*>/<!>/; print $line;

    Prints:

    <!> Not gone -->

    which most likely is not the expected result.


    Perl is environmentally friendly - it saves trees

      Hai,

      Thank you for considering me, let me tell you straight, There are two file a.txt and b.txt, i want each line of text in a.txt should be searched, if searched text found in b.txt then it has to replace with a newline along with the searched text, i hope so this will be clear to you.

      The code which you gave for replace is working only if the text come in between the open tag and closed tag,

      For example

      <! This is the sample text > -- For this the search is working fine.

      <! This is the <i>sample</i> text > -- For this the search is working till the italic closing tag not the actual closing tag.

      Regards,

      Srprabu