Copy link to clipboard
Copied
Hi All,
Pl. give me the hint to get the untagged contents using JS?
Thanks in advance.
Praveen
Copy link to clipboard
Copied
Hi Praveen,
Did you complete this? If yes pls give me the points...
Thanks in advance...
Copy link to clipboard
Copied
Hi,
untagged content has null associatedXMLElement. Once that said, loop through all the contents and check the associatedXMLElement value.
Loic
Copy link to clipboard
Copied
The untagged content has not null associatedXMLElement because its getting root XMLElement in such case....so how to find untagged content?
Copy link to clipboard
Copied
Hi,
I am surprised you get that result. If an item isn't tagged, there is no way you get returned the root xml element.
Given some content of an untagged text frame :
app.selection[0].associatedXMLElements //undefined
Unless teh content makes part of some tagged textframe, which may return the associatedXMLElements of the parent and even then, no content can be associated with the root as every tagged contents are children of the root. Do you have screenshot ?
Loic
Copy link to clipboard
Copied
The above fig represents, the selected text has placed in the middle of the "sec" tag content. so its associated element is "sec" only.
This fig, selected text has placed in an end of the document. so its associated element is root tag "book".
So how can I find the untagged content through InDesign javascript?
Copy link to clipboard
Copied
I see from that image where Loic's confusion comes from.
That paragraph you marked is not really "untagged". If you look in the Tags panel or XML Structure pane, you will see it *is* tagged, with whatever the root object is from the tags above and below this line.
In your first example, the tagged path is "body/sec", according to the Structure pane. But what do you mean this?
... so its associated element is "sec" only.
I mean, it's clear that the paragraph in itself does not have a tag. But attempting to check if an entire paragraph is not tagged seems to be a bit tricky -- I just tried with the following script (and some variations), and got mixed results.
s = app.selection[0].parentStory;
for (pp=0; pp<s.paragraphs.length; pp++)
{
p = s.paragraphs[pp];
if (p.associatedXMLElements && p.associatedXMLElements[0].parent)
{
if (!confirm (p.contents+"\r=>"+p.associatedXMLElements[0].parent.markupTag.name)) exit();
}
}
Copy link to clipboard
Copied
Hi Cenchen,
You received a response to the above question (one paragraph is missing to tag with in the xml structure)?