toddgow has asked for the wisdom of the Perl Monks concerning the following question:
I need some help and I am not finding the answer easily for some reason. I have an XML file:
<name> <![CDATA[GT Amadeus]]> </name>
There are multiple <name> and <CDATA> fields in the file. I need the next <CDATA> after the <name>.
This code pulls the <name> ...
#!/usr/bin/perl use strict; my $line = ""; open(XML,"<$file") || dir "Couldn't find $file\n"; foreach $line (<XML>){ chomp($line); $line =~ s/^\s+//g; if ($line =~ /name/{ print "$line\n"; } }
I need to find name then pull the next line...what is the best method to do this?
thanks in advance,
Todd
20090201 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find next line
by toolic (Bishop) on Jan 31, 2009 at 01:36 UTC | |
by toddgow (Initiate) on Feb 02, 2009 at 21:09 UTC | |
by toolic (Bishop) on Feb 03, 2009 at 17:51 UTC | |
by toddgow (Initiate) on Feb 05, 2009 at 23:33 UTC | |
|
Re: Find next line
by CountZero (Bishop) on Jan 31, 2009 at 08:26 UTC |