[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: Functional blocks and PCB format changes
pin:
pinNumber: 2
pinName: "rst"
x1: 1234
y1: 4321
x2: 2345
y2: 4321
layer: component
or
<pin><pinNumber>2</pinNumber><pinName>"rst"<\pinName><x1>1234<\x1><y
1>4321<\y1><x2>2345<\x2><y2>5432<\y2><layer>component<\layer><\pin>
I call the second large, bloat, and ugly.
---------------------------------------------
Here you go:
===============================
#!/usr/bin/perl -w
use strict;
use warnings;
my $filename = shift @ARGV;
use XML::LibXML;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($filename);
foreach
my $pin ($doc->findnodes('/pin')) {
my($pinNumber) = $pin->findnodes('./pinNumber/text()')->to_literal
;
my($pinName) = $pin->findnodes('./pinName/text()')->to_literal ;
my($x1) = $pin->findnodes('./x1/text()')->to_literal ;
my($y1) = $pin->findnodes('./y1/text()')->to_literal ;
my($x2) = $pin->findnodes('./x2/text()')->to_literal ;
my($y2) = $pin->findnodes('./y2/text()')->to_literal ;
my($layer) = $pin->findnodes('./layer/text()')->to_literal ;
print "pin\n";
print " pinNumber: $pinNumber\n";
print " pinName: $pinName\n";
print " x1: $x1\n";
print " y1: $y1\n";
print " x2: $x2\n";
print " y2: $y2\n";
print " layer: $layer\n";
}
=================================
Simple perl script will make things pretty again. (after you fix the
your backslashes). Only takes
one extra module (libXML) that you can apt-get on ubuntu. Going back
the other way is just as easy once
you write a parser for your format.
If size is an issue you can always store everything compressed. Then
we can have another argument about
whether we should create our own compression scheme or use an existing
one.
John Eaton
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user