Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Relative path and XML methods

$
0
0

Hi, I am learning to integrate xml with JSX, I've read the document "JavaScript Tools Guide CS6" within the Help Extend the Tool Kit menu, and I am using an example from another thread here the community is already working ... But still, I'm two questions are:

 

- Currently use an absolute path (line # 2 below) to find the file on the desktop. However, I need the relative path to find the folder that the script is (my xml file will be along with the script and not the desktop ...)

 

- In line # 12 got:

file.open ("r", "TEXT", "????");

What are these three arguments, "r", "TEXT" and "????" the open() method? I did not find documentation about the open(), read() and close() methods, know where I can find?

 

If anyone can help me I would be very grateful, thanks. Below is my code.

 

//
var file = new File("~/Desktop/bookstore.xml");
readXMLFile(file);
//
function readXMLFile(file) {        if (!file.exists) {                throw "Dont find: " + deodeURI(file.absoluteURI);        }        file.encoding = "UTF8";        file.lineFeed = "unix";        //        file.open("r", "TEXT", "????");        var bookXmlStr = file.read();        file.close();        return bookstoreXML = new XML(bookXmlStr);
};
//
writeXMLFile(file,bookstoreXML)
//
function writeXMLFile(file, xml) {        if (!(xml instanceof XML)) {                throw "Bad XML parameter";        }        file.encoding = "UTF8";        file.open("w", "TEXT", "????");        // unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"        file.write("\uFEFF");        file.lineFeed = "unix";        file.write(xml.toXMLString());        file.close();
};
//

Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>