Issue with InDesign startup script not loading images from XML import
<p>I am trying to do an XML import automatically from a startup script when a document is loaded. I am successful in getting most of the content to populate, but images are being ignored. Everything works, including images, when I do a manual 'Import XML' through the UI, or through a manual script.</p>

<p>Below is my manual script:</p>

<pre class="lang-js prettyprint-override"><code>var myDocument = app.activeDocument;
var xmlFile = File('/c/Full/Path/To/data.xml');

myDocument.importXML(xmlFile);
</code></pre>

<p>But the goal is to do it on startup. Below is my startup script:</p>

<pre class="lang-js prettyprint-override"><code>#targetengine "session"

app.addEventListener('afterOpen', function(myEvent) {
    if (myEvent.target.constructor.name !== 'Document') {
        return;
    }

    var myDocument = myEvent.target;
    var xmlFile = File('/c/Full/Path/To/data.xml');

    myDocument.importXML(xmlFile);
});
</code></pre>

<p>Below is the XML tag for the image:</p>

<pre><code>&lt;Image href="file:///C:/Full/Path/To/Image/02.png" /&gt;
</code></pre>

<p>I'm wondering if there is an issue with the <code>'afterOpen'</code> event callback, and that's the reason why it works manually using the same method, but not in the startup script.</p>