I have long thought that
Simple Modules should only be used for simple tasks, and since
I normally do way too much with my xml, I have stuck with
XML::Twig and
XML::LibXML
for the majority of my XML work. However in the case of using XML for an application config, this is what
XML::Simple excels at.
In writing a bot for a jabber server, I have come across an error that I have yet to figure out.
I have no problems getting the xml to parse until I use the
POE::Component::Jabber::Client::XMPP
module. Once I use the module and run, I get the error
The only thing I know how to parse is a string.
You have to fetch the data for me yourself. at /usr/lib/perl5/vendor_perl/5.8.5/XML/Simple.pm line 287.
Thinking that that meant I needed to read the file into a string first, I tried that, and got the same error.
Using this simple XML file:
<?xml version ="1.0"?>
<config>
<version>0.1</version>
<application>
<hostname>testme.com</hostname>
<user>monk</user>
<password>pass</password>
</application>
</config>
and this script:
use POE::Preprocessor;
const XNode POE::Filter::XML::Node
use strict;
use warnings;
use POE qw/ Component::Jabber::Client::XMPP Component::Jabber::Error /
+;
use POE::Filter::XML::Node;
use POE::Filter::XML::NS qw/ :JABBER :IQ /;
use List::Util qw/ shuffle /;
use XML::Simple;
my $config = XMLin('test.xml');
use Data::Dumper();
warn Data::Dumper::Dumper( $config );
exit(0);
I can repro the error. If I remove the 'Component::Jabber::Client::XMPP' part, the XML parses, but then my bot wouldn't work.
Has anyone run accross this and overcome the problem?
Also, I tried switching over to the Legacy module in place of the XMPP, and got the same error.
Don
WHITEPAGES.COM | INC
Everything I've learned in life can be summed up in a small perl script!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.