robjmills
robjmills

Reputation: 18598

Converting XML format

We have an issue where we have an XML feed leaving our system and a client needs to be able to import this feed into their system but they require the XML file to be in a different format. For a number of reasons its not possible for either of us to alter our format. I was thinking then that it would make sense for us to build some kind of bridge, that imports our format and exports it in theirs. Obviously this is pretty simple when we know the formats in each position. What I would like to do though is build something more generic and less specific to that client so this bridge could be used by a number of people should they need it. What should I be looking at to achieve this? There are a number of methods I can think of such as template documents containing placeholder elements and some form of mapping data (in XML or in a DB) but it seems to me there should be a more elegant solution - maybe like the PHP XSL extension. We work predominantly in PHP so a PHP-based solution would be ideal but i'd be happy to consider anything that would work on a Linux box.

Upvotes: 0

Views: 187

Answers (3)

Paul Clapham
Paul Clapham

Reputation: 1074

As far as the "transforming" part of your question is concerned, yes, XSLT would be a reasonable approach.

But as far as the "could be used by a number of people should they need it" part of the question, don't try to build a generic system based on a single example. When you have three or four clients for which you're transforming your XML, then would be the time to find out what they all have in common.

Upvotes: 3

Benoît Vidis
Benoît Vidis

Reputation: 3912

Indeed, XSLT is the way to go.

Some resources here: http://www.w3schools.com/xsl/default.asp

And the XSL extension for PHP is indeed an easy way to make it run.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799520

Yes, XSLT is fairly effective at transforming one XML format to another, hence the "T". I've used it in the past with great success.

Upvotes: 2

Related Questions