最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - how to check if an element in an html file exists in another html file?

programmeradmin4浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Imagine that I have an HTML file as one of my WordPress blog pages (let's call it page B). I want to write an if condition inside a tag on page B to check if a specific element exists on another web page (page A).

My question is what function should I choose to check this condition? Should I also import the HTML file of page A inside page B? And what should I do on the server-side, if I have to?

Thanks

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Imagine that I have an HTML file as one of my WordPress blog pages (let's call it page B). I want to write an if condition inside a tag on page B to check if a specific element exists on another web page (page A).

My question is what function should I choose to check this condition? Should I also import the HTML file of page A inside page B? And what should I do on the server-side, if I have to?

Thanks

Share Improve this question edited Oct 1, 2020 at 12:46 Shima Masaeli asked Oct 1, 2020 at 12:41 Shima MasaeliShima Masaeli 32 bronze badges 1
  • Are you referring to the post content or do you have literal .html files in your site? What problem does this solve? It's a little too abstract/generic at the moment so context will help – Tom J Nowell Commented Oct 1, 2020 at 13:10
Add a comment  | 

1 Answer 1

Reset to default 0

If I understand you correctly, and you want to find an HTML element inside another page, you need to use some HTML parser.

Take a look at https://www.php/manual/en/domdocument.loadhtmlfile.php or https://github/paquettg/php-html-parser. I believe there are more tools that can help you with this.

On page B you load page A as a remote document by URL, then parse it and look for the desired HTML element.

发布评论

评论列表(0)

  1. 暂无评论