Computing.Net > Forums > Programming > Search and replace using PERL

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Search and replace using PERL

Reply to Message Icon

Name: chaturvedi
Date: December 10, 2008 at 01:03:02 Pacific
OS: Win XP
CPU/Ram: 4 GB
Product: Dell / P4
Comment:

Can someone pls suggest a PERL script in which i can replace a string from a xml file to the html file?

Eg:

XML FILE:

<topic id="1008" title="Overview" href="HelpEnglish.htm#Overview"/>
<group title="User Interface" href="HelpEnglish.htm#USER_INTERFACE">
<group title="The Menu Bar" href="HelpEnglish.htm#The_Menu_Bar">
<topic id="1009" title="The File Menu" href="HelpEnglish.htm#The_File_Menu"/>
<topic id="1010" title="New Project" href="HelpEnglish.htm#New_Project"/>
<topic id="1011" title="Open Project" href="HelpEnglish.htm#Open_Project"/>
<topic id="1012" title="Recent Files" href="HelpEnglish.htm#Recent_Projects"/>
<topic id="1013" title="Save Project" href="HelpEnglish.htm#Save_Project"/>
<topic id="1014" title="Save As" href="HelpEnglish.htm#Save_As"/>
<topic id="1015" title="Close Project" href="HelpEnglish.htm#Close_Project"/>
<topic id="1016" title="Import Old Project" href="HelpEnglish.htm#Import_Old_Project"/>
<topic id="1017" title="Merge Project" href="HelpEnglish.htm#Merge_Project"/>
<topic id="1018" title="Split Project" href="HelpEnglish.htm#Split_Project"/>
<topic id="1019" title="Exit" href="HelpEnglish.htm#Exit"/>
</group>

HTML FILE:

<p class=MsoToc4><span class=MsoHyperlink>3.1.1.5<span
style='font-size:12.0pt;color:windowtext;text-decoration:none'>      
</span>Save As<span style='color:windowtext;display:none;text-decoration:none'>.
19</span>
</span></p>

<p class=MsoToc4><span class=MsoHyperlink><a
href="HelpEnglish.htm#Close_Project">3.1.1.6<span style='font-size:12.0pt;
color:windowtext;text-decoration:none'>       </span>Close
Project<span style='color:windowtext;display:none;text-decoration:none'> 19</span></span></p>

<p class=MsoToc4><span class=MsoHyperlink><a
href="HelpEnglish.htm#Import_Old_Project">3.1.1.7<span style='font-size:12.0pt;
color:windowtext;text-decoration:none'>       </span>Import
Old Project<span style='color:windowtext;display:none;text-decoration:none'> 19</span></span></p>

<p class=MsoToc4><span class=MsoHyperlink><a
href="HelpEnglish.htm#Merge_Project">3.1.1.8<span style='font-size:12.0pt;
color:windowtext;text-decoration:none'>       </span>Merge
Project<span style='color:windowtext;display:none;text-decoration:none'> 20</span></span></p>

<p class=MsoToc4><span class=MsoHyperlink><a
href="HelpEnglish.htm#Split_Project">3.1.1.9<span style='font-size:12.0pt;
color:windowtext;text-decoration:none'>       </span>Split
Project<span style='color:windowtext;display:none;text-decoration:none'> 23</span></span></p>

<p class=MsoToc4><span class=MsoHyperlink>3.1.1.10<span
style='font-size:12.0pt;color:windowtext;text-decoration:none'>    
</span>Exit<span style='color:windowtext;display:none;text-decoration:none'> 25</span>
</span></p>

I want that from the xml file the "href" value should be replaced in the html file where the title is same.....can someone pls suggest a script as this is very urgent.....



Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: December 10, 2008 at 09:14:31 Pacific
Reply:

There are no prewritten Perl scripts that will do what you want. You will need to write you own. There are a number of XML parser modules on cpan that will help in parsing the xml file and there are also some HTML parsers.

http://search.cpan.org/modlist/Stri...
http://search.cpan.org/modlist/Worl...

What have you tried?


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Search and replace using PERL

Perl search and replace www.computing.net/answers/programming/perl-search-and-replace/14586.html

search and replace in DOS www.computing.net/answers/programming/search-and-replace-in-dos/14876.html

Search And Replace Strings In Files www.computing.net/answers/programming/search-and-replace-strings-in-files/19734.html