File: xml2cvs.pl

package info (click to toggle)
sumo 0.15.0~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 31,740 kB
  • sloc: cpp: 109,360; xml: 49,743; ansic: 41,570; python: 20,769; java: 17,071; sh: 10,413; makefile: 1,377; perl: 450
file content (26 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if(!defined($ARGV[1])) {
	print "Syntax-Error!\n";
	print "Syntax: xml2cvs.pl <FILENAME> <TAGNAME>\n";
	print " Prints all attributes in the order of their occurence from the given tag of the given file.\n";
	die;
}


$tag = "\<".$ARGV[1];
open(INDAT, "< $ARGV[0]") || die "Could not open ".$ARGV[0];
while(<INDAT>) {
	$tmp = $_;
	if($tmp =~ $tag) {
		$beg = index($tmp, "\"");
		while($beg!=-1) {
			$end = index($tmp, "\"", $beg+1);
			print substr($tmp, $beg+1, $end-$beg-1);
			print ";";
			$beg = index($tmp, "\"", $end+1);
		}
		print "\n";
	}
}
close(INDAT);