🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
5 messages
5 total messages Started by rajeevkumar Wed, 21 Jan 2009 12:45
Import XML [JS]
#1880
Author: rajeevkumar
Date: Wed, 21 Jan 2009 12:45
13 lines
1234 bytes
Hi all,

I am trying to import XML file into chosen template, please see below. I am not able to import XML file, please help me. After importing I want to save the indesign document on the location of XML file.

var FilterID = "InDesign Template: *.indt";
var FilterXML = "XML File: *.xml";
var myFile = File.openDialog("Please choose InDesign Template", FilterID);//To choose InDesign template
var myXML = File.openDialog("Please choose XML File", FilterXML);
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
var myDoc = app.open(myFile);
//app.importXML(myFIle, myXML);

Thanks
Re: Import XML [JS]
#1881
Author: loic_aigon
Date: Wed, 21 Jan 2009 14:10
5 lines
715 bytes
Start trying this :
import into doc rather than app
You mistyped myFile (myFIle)

app.activeDocument.importXML(myFile, myXML);
Re: Import XML [JS]
#1956
Author: Lin_Xia
Date: Thu, 22 Jan 2009 00:44
46 lines
3190 bytes
Change 
  app.importXML(myFIle, myXML);
to
  myDoc.importXML(myXML);

Lin

> -----Original Message-----
> From: rajeevkumar [mailto:member@adobeforums.com]
> Sent: Wednesday, January 21, 2009 4:45 AM
> To: adobe.scripting.indesign@adobeforums.com
> Subject: Import XML [JS]
> 
> A new discussion was started by rajeevkumar in
> 
> InDesign Scripting --
>   Import XML [JS]
> 
> Hi all,
> 
> I am trying to import XML file into chosen template, please see below.
> I am not able to import XML file, please help me. After importing I
> want to save the indesign document on the location of XML file.
> 
> var FilterID = "InDesign Template: *.indt";
> var FilterXML = "XML File: *.xml";
> var myFile = File.openDialog("Please choose InDesign Template",
> FilterID);//To choose InDesign template
> var myXML = File.openDialog("Please choose XML File", FilterXML);
> app.scriptPreferences.userInteractionLevel =
> UserInteractionLevels.neverInteract;
> var myDoc = app.open(myFile);
> //app.importXML(myFIle, myXML);
> 
> Thanks
> 
> 
> ________________________________
> 
> View/reply at Import XML [JS]
> <http://www.adobeforums.com/webx?13@@.59b7926b>
> Replies by email are OK.
> Use the unsubscribe
> <http://www.adobeforums.com/webx?280@@.59b7926b!folder=.eea52bc>  form
> to cancel your email subscription.
> 
Re: Import XML [JS]
#1958
Author: rajeevkumar
Date: Thu, 22 Jan 2009 04:38
17 lines
1335 bytes
Hi All,

Thanks, I have already done that. Now I want to save InDesign document. at present if I am saving the file then it shows .xml.indd I want to remove .xml from the file name while saving.

var FilterID = "InDesign Template: *.indt";
var FilterXML = "XML File: *.xml";
var myFile = File.openDialog("Please choose InDesign Template", FilterID);//To choose InDesign template
var myXML = File.openDialog("Please choose XML File", FilterXML);
var myXMLName = myXML.fielName;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
var myDoc = app.open(myFile);
myDoc.xmlElements.item(0).importXML(File(myXML));

if(app.activeDocument.saved == false)
{
	app.activeDocument.save(new File(myXML+".indd"));
}
Re: Import XML [JS]
#1963
Author: loic_aigon
Date: Thu, 22 Jan 2009 08:20
14 lines
1029 bytes
Hi
I use this approach but they may be a better way :

var myXMLFolder = File(myXML).parent;
var myXMLName = myXML.name;
...
if(app.activeDocument.saved == false)
{
app.activeDocument.save(new File(myXMLFolder+"/"+myXMLName.split(".xml")[0]+".indd"));
}

//myXMLName.split(".xml")[0] return first part of the name
//I can't do myXML.split(".xml") so I had to reconstruct the path
//Hence I needed to know the file parent folder.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads