Jump to content

How best to merge/compare 2 XML feeds


mortoau

Recommended Posts

I am importing two XML feeds into a database. Each feed has "odds" on sporting events.

 

The problem is each feed has different names of the same sporting event.

 

For example:

 

feed 1 describes an event as "Team A vs Team B"

feed 2 describes the same event as "TEAM A v TEAM B"

 

Do I need a mapping table to have a master event ID which knows feed 1 and feed 2's name of the event is actually the same?

 

So when I import the XML feed to get the lastest odds for every event I know how to match the different names of the same event in each feed?

Link to comment
Share on other sites

if the differences are just the 2 you described (uppercase/lowecase and the fact that one says 'v' and the other says 'vs'), then just for the sake of comparison you could convert them all to lowercase and do a replace of all 'vs'

str_replace(" vs "," v",$file_contents);

 

Of course, this is just a silly fix, and also depends on how you're importing the data (string or array). a unique id per event, as you said, would be much better and easier to identify.

 

 

Link to comment
Share on other sites

To further complicate things is the placeholders can also be different. Feed1 calls the game "event" and feed2 calls the game "competition".

 

So the value and the placeholder tag are different but have the same meaning.

 

<feed1>
<event>Team A vs Team B</event>
</feed1>

<feed2>
<competition>TEAM A v TEAM B</competition>
</feed2>

Link to comment
Share on other sites

you could also build little translation arrays. Meaning: all the possible words for each placeholder (depends really on how many there are, if they're only a few, this could work fine). Like:

 

$similar1 = array("event","competition","match","game");

 

then, when you grab a placeholder name, you search through the arrays looking for it. If you use position [0] as your default name, then you can easily translate them. If there are a lot, you can build a simple database with `defaultWord`,`similarWord` and just search through that.

 

again, not the best way to solve your problem, but it should work.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.