Page 1 of 1

import. manipulate, export XML files

Posted: Wed Feb 09, 2011 5:56 am
by IGGt
Hi Guys,

I'm not sure if this is the right place, but here goes.

I have an XML document I need to import on a regular basis, but the format of that document is like this:

[text]
<xml xmlns:s='uuid:xxx'
xmlns:dt='uuid:xxx'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='dt1' rs:ctout='30'>
<s:AttributeType name='ID' rs:number='1' rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' dt:maxLength='255'/>
</s:AttributeType>
##this continues with a lot more <s:AttributeType> and <s:datatype>##
</s:ElementType>
</s:Schema>

<rs:data>
<z:row ID='123' Case_Create_Date='2011-02-02 11:59:30' Contact='Bob' . . . />
## This continues with all the data on a single line ##
</rs:data>
</xml>
[/text]

This seems a rather strange format. Anyway, I need a way of taking the data part of this XML file, and converting it to another format that I can use, the main thing being to map the tags in this document with the tags that I need, e.g.

Case_Create_Date >> DateStart

and then outputting the resulting data as either csv or xml.

I have a rather awkward set of procedures that I have created in MySQL that involves importing it as a text file and then manipulating it, but it is far from optimal, and not very easy to manage any changes to the mappings. So I was wondering if anybody could point me in the direction of doing this in PHP instead?