Ask a Question related to PERL Modules, Design and Development.
-
Mark J Fenbers #1
XML::Parser Style => Object
Does anyone have some sample code I could examine to learn how to use the
XML::Parser package when Style is set to Objects? E.g.,
my $p = new XML::Parser(Style => Objects");
$p-Parsefile("myfile.xml");
# now what?
I'm still pretty green at Perl, and maybe "now what?" is obvious to more
experienced Perl coders, but not me...
Here is an excerpt of "myfile.xml" which I'd like to be able to parse and make
use of the data somehow in my Perl code...
<?xml version="1.0 ?>
<site id="ZLPP1">
<sigstages>
<action>8.0</action>
<flood>11.0</flood>
<moderate>13.0</moderate>
<major>17.0</major>
<record>19.4</record>
</sigstages>
<observed>
<datum>
<stage units="feet">3.16</stage>
<valid timezone="EST">2004/02/14 02:15</valid>
</datum>
<datum>
<stage units="feet">3.10</stage>
<valid timezone="EST">2004/02/14 02:45</valid>
</datum>
</observed>
</site>
Mark J Fenbers Guest
-
Object Style Options
When pasting a selection of different graphics frames with different formating from one document to another. Sometimes the frames change there... -
.net recieving null object while accessing axis message style web service
Hi, Recieving null object when message style web service isaccessed from vb.net client. SOAP messages are fine. My webservice uses the method... -
Need help with Style conversion from Style object to Style key/value collection.
I am writing a custom control that derives from the DataGrid control. I would like to apply SelectedItemStyles and ItemStyles for use in my derived... -
HTML-Parser / SGML-Parser
Ok, silly question. I am writing a script to determine my router's WAN ip address and then to email me once an hour in case it changes. Currently... -
Number format German style => English style when importing CSV files into MySQL-DB
Hi there, I'm trying to import a csv file into my MySQL database. Unfortunately the number format for the price column is formatted in German... -
Mark J Fenbers #2
Re: XML::Parser Style => Object
Yes, XML::Simple works great for me! Thanks for the tip!
Mark
Michel Rodriguez wrote:
> Mark J Fenbers wrote:>> > Does anyone have some sample code I could examine to learn how to use the
> > XML::Parser package when Style is set to Objects? E.g.,
> > [...]
> > I'm still pretty green at Perl, and maybe "now what?" is obvious to more
> > experienced Perl coders, but not me...
> > [...]
> Is there any specific reason why you chose to use XML::Parser?
> XML::Parser is really a low level module, that IMHO should not be used
> directly.
>
> I think XML::Simple would work just fine in your case. It will read the
> XML into a Perl data structure. Or try XML::LibXML, or XML::Twig if you
> need more features. Look at the FAQ (
> [url]http://perl-xml.sourceforge.net/faq/[/url] once again ;--) for more information.
>
> --
> Michel Rodriguez
> Perl & XML
> [url]http://www.xmltwig.com[/url]Mark J Fenbers Guest
-
Michel Rodriguez #3
Re: XML::Parser Style => Object
Mark J Fenbers wrote:
Is there any specific reason why you chose to use XML::Parser?> Does anyone have some sample code I could examine to learn how to use the
> XML::Parser package when Style is set to Objects? E.g.,
> [...]
> I'm still pretty green at Perl, and maybe "now what?" is obvious to more
> experienced Perl coders, but not me...
> [...]
XML::Parser is really a low level module, that IMHO should not be used
directly.
I think XML::Simple would work just fine in your case. It will read the
XML into a Perl data structure. Or try XML::LibXML, or XML::Twig if you
need more features. Look at the FAQ (
[url]http://perl-xml.sourceforge.net/faq/[/url] once again ;--) for more information.
--
Michel Rodriguez
Perl & XML
[url]http://www.xmltwig.com[/url]
Michel Rodriguez Guest
-
thumb_42@yahoo.com #4
Re: XML::Parser Style => Object
In comp.lang.perl.misc Michel Rodriguez <mirod@xmltwig.com> wrote:
Of the XML solutions out there that I've seen, (mostly java ones) I still> Is there any specific reason why you chose to use XML::Parser?
> XML::Parser is really a low level module, that IMHO should not be used
> directly.
find XML::Parser (in event mode) the easiest/fastest. (I haven't messed with
that many perl modules for XML though)
Takes a little bit to get used to at first, since the documentation
introduces it as some sort of tree that is rather difficult to grok, but if
you skip passed that and get to the event model, it's easy to process XML.
(seems pretty fast too). Only difficult thing of XML::Parser I've ever been
mixed up with was dealing with name spaces.
I've done some pretty wild stuff with XML::Parser, and can say that it's
enjoyable. :-)
I'd almost rather build my own custom tree than to deal with any DOM level
stuff. (unless I were writing XML)
Jamie
thumb_42@yahoo.com Guest
-
Ben Morrow #5
Re: XML::Parser Style => Object
Michel Rodriguez <mirod@xmltwig.com> wrote:I was under the impression that XML::Parser was more-or-less> Is there any specific reason why you chose to use XML::Parser?
> XML::Parser is really a low level module, that IMHO should not be used
> directly.
deprecated now, in favour of SAX... is that not correct?
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
/Alcestis/) [ flame, and falls out of sight. ] [email]ben@morrow.me.uk[/email]
Ben Morrow Guest
-
Bart Lateur #6
Re: XML::Parser Style => Object
Ben Morrow wrote:
That was what Matt Sergeant, maintainer of most of the XML modules,>I was under the impression that XML::Parser was more-or-less
>deprecated now, in favour of SAX... is that not correct?
seems to be wanting, yes. I'm not sure I agree.
--
Bart.
Bart Lateur Guest
-
Michel Rodriguez #7
Re: XML::Parser Style => Object
Bart Lateur wrote:
I think XML::Parser should be deprecated for "regular users". It is not>>>I was under the impression that XML::Parser was more-or-less
>>deprecated now, in favour of SAX... is that not correct?
> That was what Matt Sergeant, maintainer of most of the XML modules,
> seems to be wanting, yes. I'm not sure I agree.
actively supported any more, and if you want to learn a streaming
interface, you might as well learn SAX (although SAX is lower-level than
XML::Parser if you can believe it).
XML::Parser is still useful as a basic XML parsing layer for other
modules though, that give a higher-level API: XML::Simple (can also work
on top of a SAX parser), XML::Twig, XML::DOM (although I would not
recommend using XML::DOM, but rather XML::LibXML), XML::PYX...
In the last 2/3 years the perl XML community has largely shifted from
XML::Parser (and expat), to XML::LibXML (based on libxml2), which is a
lot more powerful, giving you XML parsing but also DOM, XPath,
XInclude... The only problems with XML::LibXML is that as the library
and the module are both still work in progress, they have sometimes
stability issues, you have to find the proper combination of
libxml2/XML::LibXML that works and stick to it for a while
(<pet_peeve>and that said, XML::Parser has had its problems too: the
interface to the DTD events for example has changed quite a few times in
incompatible ways</pet_peeve> ;--)
A plus of XML::Parser is also that it comes installed with Activestate
Perl, which might make it easier for people who don't have a compiler on
their system (but note that XML::SAX::PurePerl does not need to be
compiled and can work in such an environment too).
--
Michel Rodriguez
Perl & XML
[url]http://www.xmltwig.com[/url]
Michel Rodriguez Guest



Reply With Quote

