Getting element contents from any XML structure with Extendscript in InDesign
i have following simple structure want contents out each element:
<root>
<story>
<chaptertag>"chapter 1"</chaptertag>
<subchaptertag>"sub chapter 1"</subchaptertag>
<chaptertag>"chapter 2"</chaptertag>
<subchaptertag>"sub chapter 2"</subchaptertag>
<subchaptertag>"sub chapter 2 more"</subchaptertag>
</story>
</root>
(yes, chaptertag , subchaptertag on same level)
with following lines of code, can *successfully* each of tag names:
var mydocument = app.documents.item(0);
var arrayoftagnames = mydocument.xmltags.everyitem().name;
>>> array loop lists out:
"root
story
chaptertag
subchaptertag"
however, stumped getting contents, or data each of these tag elements! want instances of contents, including 2 instances of chaptertag , subchaptertag to similar list like:
"chapter 1
sub chapter 1
chapter 2
sub chapter 2
sub chapter 2 more"
i thought following code me close:
var arrayoftagcontents = mydocument.xmlelements.everyitem.getelements().
but alas, confess somehow not operating on correct object. have solution me (aside xmlrules) solve dilemma of getting contents out? not resistant xmlrules, want know why cannot seem contents each tag element when can name tags.
my in advance.
var arrayoftagcontents = mydocument.xmlelements.everyitem().xmlcontent
might started.
More discussions in InDesign Scripting
adobe
Comments
Post a Comment