Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Opening and searching .xml file specific strings

by devendrasingh_patil (Initiate)
on Sep 13, 2012 at 06:57 UTC ( #993381=perlquestion: print w/replies, xml ) Need Help??
devendrasingh_patil has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to open.xml file for reading which does not have uniform data (which can be extracted in Hash) and then want to search for specific string. My code works fine for .txt file. however same is not working for .xml file. Please help Here is a code snippet - my $JobDirectory = 'here is my xml file path'; open FILE, "<$JobDirectory" || die "Can't open log file $!\n"; while (<FILE>) { print "$_\n"; } Here i am providing path of my xml file in $JobDirectory. Want to open the xml file for reading. Above code does not print anything. However, instead of xml file, if i put the path of .txt file, it prints content of that file.
  • Comment on Opening and searching .xml file specific strings

Replies are listed 'Best First'.
Re: Opening and searching .xml file specific strings
by davido (Archbishop) on Sep 13, 2012 at 07:01 UTC

    Not enough information has been provided for us to know why it's "not working". ..."not working" isn't an error message. It's not even a description of a problem. It's just an acknowledgement that there is a disconnect between what you expect and what you get.

    Post a minimal code snippet that demonstrates your problem. Post the error message you're getting. Post what output you were expecting, and what output is actually occurring. Then we might be able to answer reasonably well. And chances are that as you work on creating a 10 to 15 line snippet of code to demonstrate to us what's going on, you'll discover the problem along the way yourself.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://993381]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-02-20 20:18 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.