Reputation: 183
I am parsing a XML document into InDesign and than trying to change every paragraph's style.
If I do it like this:
myTextFrame.parentStory.texts.item(0).applyParagraphStyle(<<style>>);
it will change the whole text as it would be a single paragraph.
This code, however, won't work at all:
for (var i = 0; i < <<paragraphs.length>>; i++)
{
if (styles[i].isValid)
myTextFrame.parentStory.texts.item(i).applyParagraphStyle(styles[i]);
}
Also it seems that I can't call the 'applyParagraphStyle' method on 'Paragraph' class.
My XML is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<book>
<authors>
<author>Lee Roy</author>
</authors>
<title>Name of the book</title>
<subtitle>How to XML</subtitle>
</book>
</root>
Then i parse them like this:
var string = "";
for (var i = 0; i < wholeXML.length(); i++)
{
var book = wholeXML.child(i);
string += book.child("title").toString() + "\r";
string += book.child("subtitle").toString() + "\r";
}
The output would look like something like this:
Name of the book
How to XML
Now, my question is: How can I change a single paragraph's style?
Upvotes: 1
Views: 1059
Reputation: 1235
You can simply change the paragraph style of a single paragraph by setting its appliedParagraphStyle
property.
myTextFrame.parentStory.paragraphs[0].appliedParagraphStyle = "nameOfParagraphStyle";
Upvotes: 1