in reply to How to compare the data of two files (.xml and .html) using perl(regex)?
First: Please update your post and place "code" tags around your sample data and code snippet, like this:
and like this:<code> <- you need to type in these tags exactly as shown # xml data: <gname>abc</gname> <-- then you can type these exactly as shown. <pname>xyz</pname> # html data: <p>ABC</p> <p><i>xyz</i></p> </code>
Now that your data and snippet are more visible to people, I would say that there's still not enough for us to work with. Your sample data is too sparse, the code incomplete and makes no sense, and you don't give a clear explanation of what you're actually trying to accomplish. What should your script produce as output?<code> open(F2,"<F2>"); my $xml_list1="(.*)\.html"; # here the data enclosed inside the parentheses also appears when # printed. I want say the file name is "abc.html" so i want to keep # "abc" as interchangeable, so that i dont need to write/modify the # code if any filename other than abc.html occurs. close F2; #print $xml_list1."\n"; foreach my $f (@filenames) { #print $f."\n"; open(F1,"<F1>"); my $data=join("",<F1>); close F1; my $filename=substr($f,0,index($f,'.')); my $xml_list=$filename.".xml"; while($xml_list=~m//ig) # the code doesn't enter the while/if loop, seems that it finds some # error in reading the filename $xml_list, but i tried using # $xml_list1 too... but still the loop doesnt work. </code>
You might want to look at this code I posted a while ago, for using XPath expressions on a command line to extract portions of XML: Re: XPath command line utility... -- it might give you a starting point for extracting "gname/pname" elements from your xml file, and might work on the html data also.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to compare the data of two files (.xml and .html) using perl(regex)?
by Laurent_R (Canon) on Sep 21, 2014 at 21:56 UTC | |
by graff (Chancellor) on Sep 22, 2014 at 01:04 UTC |