Greetings,
I'm very basic beginner with xml-perl modules.I can't read the content of the tag which don't having any attributes.so my $hash was "
$hash->{content}" failed with errors.
In this example,
If i don't have any attributes in the "
<txworld:general> " tag, then it is throw the error.
Suggest me,Is there is any rule in xml that, attribute is mandatory for the tags ??
Sample code
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use XML::SAX::Simple qw( XMLin);
open (FH, "> test.xml") || die ("Could not create the file. $!");
print FH <<EOF;
<?xml version="1.0"?>
<txworld:data xmlns:txworld="www.toxinworld.com/xmlns">
<txworld:test name="name" version="1">
<txworld:general>100</txworld:general>
</txworld:test>
</txworld:data>
EOF
close (FH);
my $hash=XMLin('test.xml');
print STDERR Dumper($hash);
unlink("test.xml");
exit;
=item
--WITH_ATTRIBUT_OUTPUT--
$VAR1 = {
'xmlns:txworld' => 'www.toxinworld.com/xmlns',
'txworld:test' => {
'parent' => 'parent',
'version' => '1',
'name' => 'name',
'txworld:general' => {
'content' => '100',
'type' => '1'
},
'type' => 'type',
'alias' => 'alias'
}
};
--WITHOUT_ATTRIBUT_OUTPUT--
$VAR1 = {
'xmlns:txworld' => 'www.toxinworld.com/xmlns',
'txworld:test' => {
'parent' => 'parent',
'version' => '1',
'name' => 'name',
'txworld:general' => '100',
'type' => 'type',
'alias' => 'alias'
}
};
=cut
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.