• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to getting XML element into labeled textframe using javascript.

Participant ,
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

334

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

Community Expert , 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?

Votes

Translate

Translate
Community Expert ,
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"));

 

Votes

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
Participant ,
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

Votes

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
Community Expert ,
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?

Votes

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