Copy link to clipboard
Copied
Dear java expert,
I was try to script export attribute value in the .txt format. I have attached screenshot for your reference. Please suggestion me friends.
I am using system: Mac, indesign Cs6.
Advance Thanks to all
Dear friends,
I have share my java coding in below, based on the above question.
var myDocument = app.activeDocument;
var log=new File(app.activeDocument.filePath+"/log.html");
log.encoding = "UTF-8";
log.open("w");
log.writeln("<html><body><table border=1>");
log.writeln("<tr><td>Text(In template)</td><td>Found(Href Tag)</td></tr>");
FindEmail(myDocument);
log.writeln("</table></body></html>");
log.close();
alert("process Completed");
function FindEmail(elm)
{
for (var i = 0; i < elm.xmlElements.leng
...Copy link to clipboard
Copied
Dear friends,
Please tell any one suggestion in my above question?
Thanks,
Copy link to clipboard
Copied
Dear java kings,
Please tell any one suggestion in my above question?
Advance Thanks to all,
Copy link to clipboard
Copied
Dear friends,
I have share my java coding in below, based on the above question.
var myDocument = app.activeDocument;
var log=new File(app.activeDocument.filePath+"/log.html");
log.encoding = "UTF-8";
log.open("w");
log.writeln("<html><body><table border=1>");
log.writeln("<tr><td>Text(In template)</td><td>Found(Href Tag)</td></tr>");
FindEmail(myDocument);
log.writeln("</table></body></html>");
log.close();
alert("process Completed");
function FindEmail(elm)
{
for (var i = 0; i < elm.xmlElements.length; i++)
{
XMLelementName=elm.xmlElements.markupTag.name.toString();
if(XMLelementName=="img")
{
for(j=0; j<elm.xmlElements.xmlAttributes.length; j++)
{
var cc = elm.xmlElements.contents
//alert(cc);
var aa = elm.xmlElements.xmlAttributes
if(aa=="src")
{
//alert (aa);
var bb = elm.xmlElements.xmlAttributes
log.writeln("<tr><td>"+ cc +"</td><td>"+ elm.xmlElements.xmlAttributes
//alert (cc + "~~" + aa+ " ~~ " + bb);
}
}
}
FindEmail(elm.xmlElements);
}
}
Thanks,
Copy link to clipboard
Copied
Hi there is more interesting and performing imho:
var main = function(){
var doc = app.properties.activeDocument,
xmlFile = File ( Folder.temp+"/attr.xml" ),
xmlObject,
xmlAttrs, attrs = [], n = 0, i = 0,
sep = "\t";
if (!doc) return;
doc.exportFile ( ExportFormat.XML, xmlFile );
if ( !xmlFile.exists ) {
alert("Unable to read xml data");
return;
}
xmlFile.open('r');
xmlObject = XML ( xmlFile.read() );
xmlFile.close();
xmlFile.remove();
xmlAttrs = xmlObject.xpath("//*//@*");
n = xmlAttrs.length();
while ( i<n ) {
attrs [ attrs.length ] = xmlAttrs.name()+sep+xmlAttrs;
i++;
}
if ( !attrs.length ) {
alert("Could'nt find any attributes.");
return;
}
writeFile ( "Attribute Name"+sep+"Attribute Value"+"\r"+attrs.join("\r") );
};
var writeFile = function( data ) {
var file = File ( Folder.desktop+"/attributes.csv" );
file.open("w");
file.write ( data );
file.close();
file.execute();
}
main();
FWIW,
Loic
Copy link to clipboard
Copied
HI Loic.Aigon,
Thank you so match for your advance script. Very help full for me.
Just one question: Where is you are mention(add) the image tags for <img> in the script?
Example for my coding: if(XMLelementName=="img")
Please explain me friend.
Thanks
Copy link to clipboard
Copied
just edit the xpath:
//img/@*
Loic