0

I have some XML formatted as such:

<item>
    <title>Name</title>
    <id>12</id>
    <upgrade>
        <id>13</id>
        <level>2</level>
    </upgrade>
    <upgrade>
        <id>14</id>
        <level>3</level>
    </upgrade>
</item>

Ultimately from this example I want 3 nodes:

  • Title: "Name (1)" GUID: 12
  • Title: "Name (2)" GUID: 13
  • Title: "Name (3)" GUID: 14

I'm quite happy to do 2 runs of the file if necessary. I have one importer at the moment which sets up the "Name (1)" items. This works perfectly.

I have a second importer set up which I can successfully create the secondary "upgrade" nodes but only if I use \item\upgrade as the context, at which point I lose the title element so the nodes come through as " (2)", " (3)" etc.

If I use \item as the context like the initial importer, I can't seem to loop through the upgrade XML nodes.

0

Answered on drupal.org

Import will need to be done using the context \\item\upgrade.

Then to target the title from the parent node, use ..\title.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.