Insert XML Image into Table Cell
Hello all,
I have an xml file of products including references to the image of each product.
I'm trying to transform the xml into a table after import into Indesign CS3.
Here's the general structure of the xml:
<Root>
<Product>
<Image href="file://./00257-00257.tif"/>
<Code>00257</Code>
<Price>126,00</Price>
</Product>
</Root>
And here's my script:
function main(){
var myDocument = app.activeDocument;
//Add tag elements
var myRowTag = myDocument.xmlTags.add("row");
var myCellTag = myDocument.xmlTags.add("cell");
var myTableTag = myDocument.xmlTags.add("table");
//Add XML elements.
var myRootXMLElement = myDocument.xmlElements.item(0);//Root
var myProducts = myRootXMLElement.xmlElements;
//Create elements for table
with(myRootXMLElement){ //First with
var myTableXML = xmlElements.add(myTableTag);
with(myTableXML){
for(var myRowCounter = 0; myRowCounter < myProducts.length -1; myRowCounter++){ //First for
var myProducts = myRootXMLElement.xmlElements.item("Product");
var myProduct = myProducts[myRowCounter];
with(xmlElements.add(myRowTag)){ //Second with
var myProductXMLElements = myProduct.xmlElements;
for(var myCellCounter = 0; myCellCounter < myProductXMLElements.length; myCellCounter++){ //Second for
with(xmlElements.add(myCellTag)){ //Third with
var contents = myProductXMLElements[myCellCounter].contents;
} //end of third with
} //end of Second for
} //end of second with
} //end of di First for
} //end of first with
}
//Remove old tags from Structure
myProducts.remove();
//Create table
var myTable = myTableXML.convertElementToTable(myRowTag, myCellTag);
}
main();
Here's the result (inside Indesign):
<Root>
<table>
<cell></cell>
<cell>00257</cell>
<cell>126.00</cell>
</table>
</Root>
The problem is I can't insert the image into its cell: any suggestions?
Thanks
