Copy link to clipboard
Copied
1) I'm an almost complete noob when it comes to XML
2) I have an XML with a ssstructure like this:
<chapter>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
<list type="disk">
<listitem>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
</listitem>
<listitem>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
</listitem>
<listitem>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
</listitem>
</list>
<list type="square">
<listitem>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
</listitem>
<listitem>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
</listitem>
<listitem>
<paragraph> bla bla </paragraph>
<paragraph> bla bla </paragraph>
</listitem>
</list>
</chapter>
Is there a easyer way (except iterating all the xmlElements) to find all the lists and apply the appropriate paragraph style (i have a "list_with_disk" paragraphstyle, and a "list_with_square" one)?
Hi Vamitul,
Please try the below JS code.
...var myDoc = app.activeDocument;
//____________________ disk bullet style apply
try{
var rootElement = myDoc.xmlElements.item(0);
var linkElementList = rootElement.evaluateXPathExpression("//list[@type='disk']//paragraph");
for(i=linkElementList.length-1; i>=0; i--){
var myAttribute = linkElementList;
myAttribute.xmlContent.appliedParagraphStyle = myDoc.paragraphStyles.itemByName("Disk");
}
}catch(e){}
//_______________________
Copy link to clipboard
Copied
Hi Vamitul,
Please try the below JS code.
var myDoc = app.activeDocument;
//____________________ disk bullet style apply
try{
var rootElement = myDoc.xmlElements.item(0);
var linkElementList = rootElement.evaluateXPathExpression("//list[@type='disk']//paragraph");
for(i=linkElementList.length-1; i>=0; i--){
var myAttribute = linkElementList;
myAttribute.xmlContent.appliedParagraphStyle = myDoc.paragraphStyles.itemByName("Disk");
}
}catch(e){}
//_______________________________________________________________________________
//____________________ Squar bullet style apply
try{
var rootElement = myDoc.xmlElements.item(0);
var linkElementList = rootElement.evaluateXPathExpression("//list[@type='square']//paragraph");
for(i=linkElementList.length-1; i>=0; i--){
var myAttribute = linkElementList;
myAttribute.xmlContent.appliedParagraphStyle = myDoc.paragraphStyles.itemByName("Square");
}
}catch(e){}
//_______________________________________________________________________________
thx,
csm_phil
Copy link to clipboard
Copied
thanks.