Create inline text frame from contents of an xml tag?
Hi! I have a rather large document created from an XML file, and I'd like to convert a series of my XML tags to anchored text frames so I can hang them off the left edge of lines they appear in.
My XML file is laid out as
>root
>chapter
>para
>id
1
>verse
text
>id
>verse
etc... see file snippet here http://1drv.ms/1dX6lYO
So far I have the following, which gets me an array containing all the id elements.
var myDocument = app.activeDocument;
var myXMLidElement = myDocument.xmlElements.itemByName("book").xmlElements.itemByName("c").xmlElements.itemByName("p").xmlElements.itemByName("id");
var myXMLidText= (myXMLidElement.contents);
var myXMLidLength = myXMLidText.length;
for (var i = 0; i < myXMLidLength; i++) { //loop to go through
//alert (myXMLidText);
myDocument.select(myXMLidText[0]); //this gives me an error saying expected data type needs to be array. Can someone explain? Where do I find info on the select command?
myDocument.selection[0].insertionPoints[0].textFrames.add(myXMLidText[0]); //haven't managed to get to this line yet, but I want it to create an inline text frame at the point of the selected text and set the frame's contents to be my XML Id Text
I suppose I'd then want to delete all my id text too, but that's unimportant.
Some other random snippets I could use?
myInlineFrame.contents = "myXMLidText";
Any pointers on creating the inline frames and logic loop? I'm an old hand with InDesign, but new to scripting, so be gentle.
