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

rp7’s picture

Duh...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 :)

rp7’s picture

Status: Active » Fixed

Attributes 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. :)

mikeryan’s picture

Note that the xpath should work as ->xpath('/drink/@type').

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.