Hi good people
I am trying to pass some html code from one Wordpress installation to another. But of course the two installations has slightly different configurations, so I have to alter the html of the content.
My use case is this:
- First I want to identify certain elements in the html-code.
- Then I want to remove some from the html-code. But the test of the code has to remain html.
For example - here is an html input coming into make.com:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Article Title</title>
</head>
<body>
<header>
<h1>Welcome to My Article</h1>
</header>
<article>
<h2>Introduction</h2>
<p>This is the introduction of the article. It sets the stage for the content that will follow. Here you can include interesting facts, figures, and foreshadow the main points that will be covered.</p>
</article>
<div class="subsection">
<h2>Main Section</h2>
<p>This is the main section of the article. This part is significantly important as it carries the core information intended for the reader. It's advisable to break it down into several paragraphs to enhance clarity and reader engagement.</p>
<h3>Subsection A</h3>
<p>Details about Subsection A come here. It’s good to include data, statistics, and other in-depth info that supports the main article topic.</p>
</div>
<footer>
<p>Copyright © 2024 Your Website</p>
</footer>
</body>
I want to get everything within the title tag and the article tag:
- So “Article title” should be output number 1.
- And this should be output number 2:
<h2>Introduction</h2>
<p>This is the introduction of the article. It sets the stage for the content that will follow. Here you can include interesting facts, figures, and foreshadow the main points that will be covered.</p>
Then I want the rest of the html without the two first outputs and without the footer to be output 3.
So first I will remove output 1, then remove output 2, then look for the footer tag and remove it. And then output 3 should be:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<header>
<h1>Welcome to My Article</h1>
</header>
<div class="subsection">
<h2>Main Section</h2>
<p>This is the main section of the article. This part is significantly important as it carries the core information intended for the reader. It's advisable to break it down into several paragraphs to enhance clarity and reader engagement.</p>
<h3>Subsection A</h3>
<p>Details about Subsection A come here. It’s good to include data, statistics, and other in-depth info that supports the main article topic.</p>
</div>
</body>
I have tried to work with arrays and with the built in opportunities to “replace” and to “get”. But I can’t seem to get my head around the right solution.
Can any of you guide me towards the correct tools to use? Then I will try to code it following your examples.
Thank you in advance.
Best regards,
Rasmus MP