the authors of some simpler perl dom parsers for xml seem to hinder their use for mixed content in favor of XML :: LibXML. so I'm starting to learn XML :: LibXML right now and am looking for examples of a shared cookbook. think about reading (x) html documents from the Internet and do some operations with it. (The 2nd edition of the perl cookbook is now 10 years old, and its coverage here is relatively weak.) I realized that I want to start with:
use XML::LibXML;
my $dom = XML::LibXML->load_xml( location => "fame-1-1.html", recover => 2 );
good examples of recipes starters can use include
converting $ dom to the perl data structure. Data :: Dumper ($ dom) did not bring me anything particularly interesting. Of course, I want to transform both ways: from and to.
it’s enough to print the output, perhaps with some control.
html sanitization in xhtml.
performing conversions with logic. (there are good examples of doing things with individual dom elements, but I think they are more generalizable). For example, how can I work with two consecutive dom elements? I have an XAB. I want to add a "class" or "style" to sup, if this is consistent (for example, style = "width: 0").
display all classes and styles in a minimal template style sheet.
other "cool" and "simple" applications for XML :: LibXML.
(on the left for further editing the question in response to useful recipes):
(a) list with incremental id each <li> inside <ul> (for example, <li id = "1"> ... <li id = "2"> ...). can be performed with several elements
(b) (, li, dl dt)
.
/IAW