Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to getting XML element into labeled textframe using javascript.

Explorer ,
Jul 26, 2021 Jul 26, 2021

Copy link to clipboard

Copied

Hi Team, 

I am tring to get XML element into a labeled textframe. but am getting error as "XMLelement us read only".
Sample Code:

 

var XMLElement = app.activeDocument.xmlElements[0];
XMLElement.placeXML(app.activeDocument.pages[0].textFrames.itemByName("FIRST"));

 



kindly refer attached snap.

 

BalajiMurugesan_0-1627320004804.png

 

TOPICS
Scripting

Views

53

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 26, 2021 Jul 26, 2021
Check that the text frame isValid before passing it to the placeXML method. It does not appear that you have a valid text frame. What does your layer panel look like with that green frame selected?

Likes

Translate

Translate
Adobe Community Professional ,
Jul 26, 2021 Jul 26, 2021

Copy link to clipboard

Copied

Just change the name of your variable. There's a reason why "my" is used at the start of variable names in sample code.  You're trying to access the DOM with that variable name. 

var myXMLElement = app.activeDocument.xmlElements[0];
myXMLElement.placeXML(app.activeDocument.pages[0].textFrames.itemByName("FIRST"));

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2021 Jul 26, 2021

Copy link to clipboard

Copied

Thanks @brianp311,

But getting another error,

I need place XML element into a labeled textframe.

 

BalajiMurugesan_0-1627321110842.png

 

But facing error.

 

Advance Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 26, 2021 Jul 26, 2021

Copy link to clipboard

Copied

LATEST

Check that the text frame isValid before passing it to the placeXML method. It does not appear that you have a valid text frame. What does your layer panel look like with that green frame selected?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines