We need to modify/update the xml attribute of .idms file. using actionscript. I'm using below approach to do that.
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
var file:File = File.desktopDirectory.resolvePath('myInputFile.xml');
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);// doesn't read processing instrunction
var xml:XML = new XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
fileStream.close();
var writeStream:FileStream = new FileStream();
writeStream.open(file, FileMode.WRITE);
for each(var node:XML in xml.descendants("*"))
{
if(node.localName() == "Link")
{
var linkfile:String=node.@LinkResourceURI = "file:/Shared/Logos/Bk.ai";
}
}
writeStream.writeUTFBytes(String(xml));
writeStream.close();
}
In above code problem is that it does not read processing instruction on top of xml file. in result after writing the xml file, it won't read the file as InDesign snippet file anymore. Processing instrunctions are:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Can anyone help me in figure out how I can I read the processing instrunction as well in new file ?
Thanks for quick reply but Even though I've made this property as flase it's keep ignoring the processing instuction.
var file:File = File.desktopDirectory.resolvePath('031413115849909.idms');
var fileStream:FileStream = new FileStream();
XML.ignoreProcessingInstructions = false; //newly added
fileStream.open(file, FileMode.READ);
var xml:XML = new XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
fileStream.close();