logo       

RE: templating question [long-ish]: msg#00008

lang.perl.xml

Subject: RE: 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"

This question is asked often, in various ways. I'm not familiar with
XML::Smart, but extracting mixed content can be done with XML::Twig or
XML::LibXML. Here's some working XML::LibXML code:

use XML::LibXML;
my $dom = XML::LibXML->new->parse_string(qq(
<entry>
<title>Foo</title>
<text>The text <strong>here</strong> is bold</text>
</entry>
));

#The following prints "The text <strong>here</strong> is bold"
foreach $textNode ($dom->findnodes('//entry/text/node()')) {
print $textNode->toString();
}



--
Mark Thomas Thomas.Mark@xxxxxxx
Internet Systems Architect User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;


_______________________________________________
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