Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: HTML content editing using HTML::TreeBuilder

by skleblan (Sexton)
on Apr 10, 2019 at 23:10 UTC ( [id://1232427]=note: print w/replies, xml ) Need Help??


in reply to HTML content editing using HTML::TreeBuilder

As Tux mentioned, it would be helpful to see some sample code. I can only offer some general suggestions.

I will say that it can be tricky when you are using HTML::TreeBuilder to search for "text". In the following example, the visual text that you see displayed is actually split up between different nodes.

<h2><i>Real-Life</i> Police Investigations</h2>

This might be related to why you see different numbers of child contents. Another example is

<div id=1> <div id=2> <h2>Spring 2019 Season</h2> <div id=3> Content...

Whenever I'm searching for text as it's displayed to the user, I definitely take advantage of the as_text() method of HTML::Element. Maybe check if you are at the deepest/shallowest level by checking if the as_text() result of the current node is the same/different as the as_text() result of the parent/child node.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found