Any documentation on XML importing


(Douglas (@finnatic at @waikato)) #1

I'm investigating what we can and can't do with importing structured XML into Matrix - is there any documentation (manuals etc) that I can look at?


(Mark Brydon) #2

It is possible to import XML as assets into Matrix from the command line, however there is no documentation for these scripts. This is a rather advanced area of Matrix with many import actions and settings. The best way to understand how to generate an XML import is to run the export_from_xml script on some a small asset structure which matches that which you would like to import.



For example (from the Matrix System Root directory):

php import/export_to_xml.php `pwd` 456 123 1 > export.xml



This command will export an XML representation of asset attributes and linking for asset 456 and its children. The output will be directed into export.xml and this file will be ready for import into another Matrix system of the same version (with import_from_xml) under asset 123, and will be linked as TYPE_1.



It is recommended that any import actions be performed on a test system, or that Squiz Support is involved in the process to ensure that the XML provided will not result in any import issues.


(Douglas (@finnatic at @waikato)) #3

Hi Mark, thanks for that response.

[quote]It is recommended that any import actions be performed on a test system, or that Squiz Support is involved in the process to ensure that the XML provided will not result in any import issues.[/quote]



What are the risks of doing imports?



I'm assuming that as long as I have parentid set right I should see any imported assets under the parent in the asset tree?


(Dw Andrew) #4

Some things I usually cut out are designs and permissions, I never have a clone close enough to the source system to be able to just run the export then import (users having different asset ids etc) and they are easy to add, with some effort you could just fix the XML though. So you're correct, once you have the import location set i think you are pretty safe - if any errors occur just delete the created assets and edit the XML.


(Mark Brydon) #5

[quote]What are the risks of doing imports?
I'm assuming that as long as I have parentid set right I should see any imported assets under the parent in the asset tree?[/quote]

That's right, assuming everything is set up correctly you should have no problems.



There is no validation performed on data imported via "import_from_xml" and incorrect data can potentially corrupt existing assets, which is why we recommend assistance in this process. With an appropriate backup mechanism in place, or better still testing first on a duplicate system away from your production environment, the potential risks can be minimised.


(Bruce Cockings) #6

[quote]For example (from the Matrix System Root directory):
php import/export_to_xml.php `pwd` 456 123 1 > export.xml



This command will export an XML representation of asset attributes and linking for asset 456 and its children. The output will be directed into export.xml and this file will be ready for import into another Matrix system of the same version (with import_from_xml) under asset 123, and will be linked as TYPE_1.[/quote]



I need to do some research on the importing/exporting of data into our Squiz environment as we have a lot of data to move into our squiz environment. I have searched for documentation on the scripts and the above quote is the best thing I've found so far!!!!



Is there any documentation on these scripts 'export_to_xml.php' and 'import_from_xml.php'?



No documentation on these scripts is very frustrating, as on our system I do not have access to run the scripts because as you state it can cause problems with the squiz matrix, so I need to submit a request to the infrastructure team to run the import/export scripts. Asking them to run the script and let me know what error message they get, then ask them to re-run the script again with an updateded parameters to try and fix the error is not an option.



Could you explain the line:



php import/export_to_xml.php `pwd` 456 123 1 > export.xml



php = command prompt?

import = directory?

export_to_xml.php = script name

'pwd' = some password?

456 = asset to export

123 = ?

1 = ?

export.xml = file to export data to.



Could you also give an example for the import_from_xml.php?



Cheers


(Dw Andrew) #7

php = php executable path, you're running php from command line
scripts/import/export_to_xml.php = (when you are in your matrix root) path to the php script

'pwd' = the unix pwd command (will output your current location (matrix root path))

456 = root asset to export

123 = asset you are going to import under

1 = link type





Import is simpler:

from matrix root

php scripts/import/export_to_xml.php `pwd` /path/to/export.xml









Hit up your sysadmins for some access :stuck_out_tongue:


(Bruce Cockings) #8

I have managed to get the export script run, and now have an XML file for the export of a standard page. :slight_smile:


I now need to import about 100 standard pages and have a few questions on how to do that so will start a new thread in support.



Thanks for the help.