[TYPO3-dev] Processing complex XML data

Steffen Müller typo3 at t3node.com
Tue Mar 24 21:56:55 CET 2009


Hi.

I'm struggling with handling XML data which I import from Amazon AWS. I
hope to get some ideas from you.

I'm coding an extension which requests XML data from AWS using REST.
My idea was to transform the XML to an array for further processing, but
it turned out that this is not trivial at all.
There's two properties of the XML data which turned out to be a problem:

1) some elements are used several times:
<author>Person1</author>
<author>Person2</author>

2) elements sometimes have attributes:
<creator role="editor">Person3</creator>
<creator role="translator">Person4</creator>

I tried t3lib_div::xml2array() but it does not support 1). I did not
find other satisfying solutions in the web which both could handle 1) and 2)
Then I tried simplexml_load_string() and used an object instead of an
array. But the code got rather complex and looked ugly, because I had to
use type casting and juggle with several objects. Also TYPO3 API mostly
expect array parameters not objects.

Maybe someone has a good recommendation on how to handle complex XML as
data basis.

Does the CR of FLOW3 have a XML model API?

-- 
cheers,
Steffen

http://www.t3node.com/




More information about the TYPO3-dev mailing list