Hi,
xml data with contains attribute values.
XML Data:
<chapter>
<div class="figure" id="s9781452281988.n9.i73">
<p class="fig-caption" name="Figure 9.2.">Prevention of, and Treatment for, Mental Health, Substance Abuse, and Family Conflict</p>
<img src="10.4135_9781452281988-fig0902.jpg" alt="Figure 9.2. Prevention of, and Treatment for, Mental Health, Substance Abuse, and Family Conflict"/>
</div>
</chapter>
JavaScript:
var myDoc = app.activeDocument;
var myGlueCodePath = app.filePath + "/Scripts/XML Rules/glue code.jsx";
var myFile = File(myGlueCodePath);
app.doScript(myFile);
if (app.documents.length != 0) {
var myRuleSet = new Array(
new findObjAttribute("//*")
);
with(myDoc) {
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
}
}
else{
alert("You have no document open!");
exit();
}
function findObjAttribute(){
this.name = "findObjAttribute";
this.xpath = ("//div[@class='figure']//p[@class='fig-caption']");
this.apply = function(myElement, myRuleProcessor)
{
var elmName=myElement.markupTag.name;
with(myElement){
try {
var myAttName=myElement.xmlAttributes.itemByName("name").value;
$.writeln(myAttName);
}catch(e){};
}
}
}
my Problem is After import xml in to InDesign i will get output like:
Prevention of, and Treatment for, Mental Health, Substance Abuse, and Family Conflict
But am expecting with attribute name following contents
Figure 9.2 Prevention of, and Treatment for, Mental Health, Substance Abuse, and Family Conflict
can any one modify my Script
Hurix