PHP - Find difference in 2 strings and get path to difference

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Oct 30, 2017 9:37 am

Mon Oct 30, 2017 9:42 am

I got 2 html files which use same template only some fields different and i need to get full xpath to those differences using PHP.


<div class="price">12,400</div>
<div class="make">Acura</div>


<div class="price">15,400</div>
<div class="make">Bmw</div>

So as you can see from example its the same template but price is different and make So PHP script suppose to show xpath (those results):


Script needs to find difference in 2 files and get xpath to that difference, obviously template is unknown and every time could be different

Any Help Appreciated!!!

User avatar
php-forum Fan User
php-forum Fan User
Posts: 801
Joined: Mon Feb 22, 2016 5:52 pm

Mon Oct 30, 2017 1:41 pm

I'm not sure what you are trying to achieve, but it seems that you are creating a problem that doesn't or shouldn't exist?

You have a template html file, and then populate the fields from your script; unless I'm misunderstanding you, why would you then want to extract that same data?

User avatar
New php-forum User
New php-forum User
Posts: 55
Joined: Mon Oct 16, 2017 1:06 pm

Mon Oct 30, 2017 2:04 pm

This sounds like a classic XY Problem, A.K.A help me fix my attempted solution. OP, tell us what the real problem is that you are trying to solve, not your attempt at solving it.

I don't see anything that resembles a proper "template".
The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

Post Reply