Closed (fixed)
Project:
Migrate
Version:
7.x-2.0-rc3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2011 at 15:48 UTC
Updated:
7 Apr 2011 at 16:21 UTC
Following the example (wine.inc), I managed to get importing from XML working. I wonder though - is it possible to retrieve XML attributes for migration? I have an XML file which is sort of like the example below:
<drink type="lemonade">
<price>2.50</price>
<amount>20</amount>
<supplier>Pepsico</supplier>
</drink>
How do I retrieve the "type" value (lemonade)? Tried ->xpath('/drink@type'), but without succes.
Comments
Comment #1
rp7 commentedDuh...checking out the $row variable in the prepare function through watchdog made a lot of things clear. Obvious solution....available in the SimpleXML-object, with the '@attributes' key.
It only contains the attributes of the parent object though, not of children. Probably something to do with the function simplexml_load_file which is being used. Still digging in that - will reprort later :)
Comment #2
rp7 commentedAttributes of a SimpleXML object can be retrieved through the '->attributes()' function. Was able to answer my own questions just digging into SimpleXML - guess I was too fast asking them in the first place. Closing this. :)
Comment #3
mikeryanNote that the xpath should work as ->xpath('/drink/@type').