XML Data merging

This is a discussion on XML Data merging within the PHP General forums, part of the PHP Programming Forums category; I'm using simplexml to fetch data from a set of data files. If I have two files, and one ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2008
Naz Gassiep
 
Posts: n/a
Default XML Data merging

I'm using simplexml to fetch data from a set of data files. If I have
two files, and one is an update to the other, is there an easy way to
merge the two files together, rather than having write logic that checks
one and then the other?

Both files conform to the same DTD and thus the data in the update will
perfectly eclipse the data in the main file. If I can do this it would
save me writing a whole bunch of logic.

Thanks,
- Naz.
Reply With Quote
  #2 (permalink)  
Old 01-12-2008
Eric Butera
 
Posts: n/a
Default Re: [PHP] XML Data merging

On 1/12/08, Naz Gassiep <naz@mira.net> wrote:
> I'm using simplexml to fetch data from a set of data files. If I have
> two files, and one is an update to the other, is there an easy way to
> merge the two files together, rather than having write logic that checks
> one and then the other?
>
> Both files conform to the same DTD and thus the data in the update will
> perfectly eclipse the data in the main file. If I can do this it would
> save me writing a whole bunch of logic.
>
> Thanks,
> - Naz.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


diff!
Reply With Quote
  #3 (permalink)  
Old 01-12-2008
Steve Edberg
 
Posts: n/a
Default Re: [PHP] XML Data merging

At 12:10 PM -0500 1/12/08, Eric Butera wrote:
>On 1/12/08, Naz Gassiep <naz@mira.net> wrote:
>> I'm using simplexml to fetch data from a set of data files. If I have
>> two files, and one is an update to the other, is there an easy way to
>> merge the two files together, rather than having write logic that checks
>> one and then the other?
>>
>> Both files conform to the same DTD and thus the data in the update will
>> perfectly eclipse the data in the main file. If I can do this it would
>> save me writing a whole bunch of logic.
>>
>> Thanks,
>> - Naz.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

>
>diff!



....Although your standard diff wouldn't account for files that parse
identically but have slightly different but functionally identical
XML (eg; differing case/whitespace in tags, different order of
attributes). That's what tools like XMLdiff (python) -

http://www.logilab.org/project/xmldiff

- xmldiff (perl) -

http://www.xml.com/pub/r/1354

- xmldiffpatch (MS executable) -

http://msdn2.microsoft.com/en-us/library/aa302294.aspx

- and probably numerous others are for. Here's a possibly-useful article:

http://www.xmlhack.com/read.php?item=1681

Disclaimer: I've never used any of those tools, so YMMV, IANAL, RTFM,
LOL, etc...

steve


--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center sbedberg@ucdavis.edu |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
Reply With Quote
  #4 (permalink)  
Old 01-14-2008
Naz Gassiep
 
Posts: n/a
Default Re: [PHP] XML Data merging


Eric Butera wrote:
> On 1/12/08, Naz Gassiep <naz@mira.net> wrote:
>
>> I'm using simplexml to fetch data from a set of data files. If I have
>> two files, and one is an update to the other, is there an easy way to
>> merge the two files together, rather than having write logic that checks
>> one and then the other?
>>
>> Both files conform to the same DTD and thus the data in the update will
>> perfectly eclipse the data in the main file. If I can do this it would
>> save me writing a whole bunch of logic.
>>
>> Thanks,
>> - Naz

>
> diff!


Could I trouble you to elaborate? Or at least point to the RTFM url.
- Naz.
Reply With Quote
  #5 (permalink)  
Old 01-14-2008
Jim Lucas
 
Posts: n/a
Default Re: [PHP] XML Data merging

Naz Gassiep wrote:
>
> Eric Butera wrote:
>> On 1/12/08, Naz Gassiep <naz@mira.net> wrote:
>>
>>> I'm using simplexml to fetch data from a set of data files. If I have
>>> two files, and one is an update to the other, is there an easy way to
>>> merge the two files together, rather than having write logic that checks
>>> one and then the other?
>>>
>>> Both files conform to the same DTD and thus the data in the update will
>>> perfectly eclipse the data in the main file. If I can do this it would
>>> save me writing a whole bunch of logic.
>>>
>>> Thanks,
>>> - Naz

>>
>> diff!

>
> Could I trouble you to elaborate? Or at least point to the RTFM url.
> - Naz.
>


once you have the data from simplexml, use http://us3.php.net/array_diff to get the differences
between the two data sets.


--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:56 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0