logo       

templating question [long-ish]: msg#00005

lang.perl.xml

Subject: templating question [long-ish]

So I'm using an XML database to store a bunch of info
for my website. Some of the fields also contain
formatting so an entry might go something like:
<entry>
<title>Foo</title>
<text>The text <strong>here</strong> is bold</text>
</entry>

Up till now the only XML module I could make heads or
tales of (being new to XML and not so good with OOP)
has been XML::Smart, but from what I can discern
there's no way to get "The text <strong>here</strong>
is bold" or something resembling it using that module,
without CDATAing everything. I base this on the
following hack:
#!perl -w
use strict;
use vars qw($XML);
use XML::Smart;

$XML = XML::Smart->new(\*DATA, 'XML::Smart::Parser')
or die "Couldn't open XML database:$!";
$XML->main::xmlprint();
sub xmlprint {
my $this = shift;
my ($data,$unicode) = $this->data(@_) ;
print $data;
}
__DATA__
<?xml version="1.0"?>
<root>
<level1>Begin <level2>test</level2> end</level1>
<level1>Begin without end
<level2>test2</level2></level1>
<level1><level2>test3</level2> End without
begin</level1>
<level1><level2>test4 no end or
begin</level2></level1>
<level1>Begin and end with no test</level1>
<level1>Begin and end with null test
<level2></level2></level1>
<level1>Begin <level2>single</level2> and
<level2>double</level2> test</level1>
<level1>Begin <level2>single</level2> and
<level3>tripple</level3> test</level1>
<level1>Begin <level2>single</level2> and
<level2><level3>tripple</level3></level2>
test</level1>
<level1><![CDATA[cdata
<level2>test</level2>]]></level1>
</root>
__END__

So my question is, is there a way to get data
resembling "The text <strong>here</strong> is bold"
back with XML::Smart? And if not, what would be a
good, simple module to do this with? (I get the
impression stream modules would be able to do it fine,
but that makes things more difficult with other parts
of the program.)

Thanks,
~wren

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
_______________________________________________
Perl-XML mailing list
Perl-XML@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise