Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

This looks like a very simple DOM manipulation: delete nodes from the DOM. I can do that in Firefox's developer tools. I am sure any DOM manipulator can do that. Specifically the Mojo::DOM suggested by marto should also be able to do it - but I have not used it before. In short: parse your html and convert it to a DOM, which is a Tree of html-tag nodes. Locate the node by xpath or other exotic selector. Zap the node and/or its children. Work at as high level as you can with this one because the spec will continually change and change and it will come to bite you.

Edit: I am not sure if the process of HTML -> DOM -> manipulate -> HTML will retain exactly the white spaces from the original HTML between tags as it seems you want to keep them given the test cases you provided.

Add: a regex "is simpler" but it isn't.

bw, bliako


In reply to Re^7: Looking for a module that strips an HTML tag and its associated 'TEXT' by bliako
in thread Looking for a module that strips an HTML tag and its associated 'TEXT' by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2021-12-02 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (18 votes). Check out past polls.

    Notices?