[H-GEN] How do I reference this in perl?

Michael Anthon michael at anthon.net
Sat Jul 6 07:21:47 EDT 2002


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

I'm attempting to do something in perl that is *way* beyond my abilities.
The basic thrust of what I am attempting is to convert an XML document from
glade into another XML document suitable for XWT.

I was hoping to get XML::Parser to do all the hard work for me however I
have come a little unstuck.

Using this code....
************************************************
#!/usr/bin/perl

use strict;

use XML::Parser;
use Data::Dumper;

my $p = new XML::Parser(Style => "Objects", Pkg => 'Glade');

my $file = shift;
my $tree;
if (defined $file) {
  $tree = $p->parsefile($file);
}
else {
  $tree = $p->parse(*STDIN);
}
print Dumper($tree);
***************************************************

Gives me this file http://home.anthon.net/~mca/xwt/glade2xwt/object_dump.txt
when fed this file
http://home.anthon.net/~mca/xwt/glade2xwt/sample/sample.glade

The doco for XML::Parser has this to say about using the object style...
***************************************************
This is similar to the Tree style, except that a hash object is created for
each element. The corresponding object will be in the class whose name is
created by appending ``::'' and the element name to the package set with the
Pkg option. Non-markup text will be in the ::Characters class. The contents
of the corresponding object will be in an anonymous array that is the value
of the Kids property for that object.
***************************************************

Now, I have no clue what so ever how to reference elements in the class and
I was hoping someone could tell me how to do it please.

Cheers
Michael


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list