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

DOM Parser not working in IDJS script

Explorer ,
Aug 02, 2023 Aug 02, 2023

Hi All,

 

I'm developing the UXP scripts for InDesign. While reading the HTML file, we use a DOM Parser to read the HTML file.

 

our UXP is not supporting to read the DOM parser. Kindly any one resolve this and will appreciate. 

 

//======================================

const file = await ufs.getFileForOpening({mode: uxpfs.modes.readWrite, type: "file"});

const text = await file.read({format: formats.utf8});

if (window.DOMParser) {
const parser = new DOMParser();

var manifest = parser.parseFromString(text, "text/xml");

}

//==================================

 

Thanks & Regards,

Harihara Sudhan T R.,

 

TOPICS
UXP Scripting
921
Translate
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 ,
Aug 02, 2023 Aug 02, 2023

Seems DOMParser is not available to UXP. Untill this is implemented by Adobe I suppose you will have to rely on alternate means. I am not sure if we can use node packages with UXP, if we can then you can look at https://www.npmjs.com/package/dom-parser

-Manan

Translate
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 ,
Aug 02, 2023 Aug 02, 2023

The following link talks about using nodejs packages with UXP

https://adobexdplatform.com/plugin-docs/reference/javascript/javascript-support.html#can-i-use-npm-p...

Could be possible, but you will have to test it

-Manan

Translate
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 ,
Aug 03, 2023 Aug 03, 2023

Dear Mannan,

 

Really this is helpful for me and thank you for your Kind support.

Translate
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 Employee ,
Aug 03, 2023 Aug 03, 2023

That's the old documentation page for XD, the newer page is here: https://developer.adobe.com/xd/uxp/develop/plugin-development/javascript-and-xd/javascript-support/

 

That said, have you tried this with InDesign 18.5? It just came out in prerelease and has many more UXP features...

Translate
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 ,
Aug 05, 2023 Aug 05, 2023
LATEST

Thanks for the update URL @erinferinferinf. I see the new article also has the same advice on the topic so @Harihara28692478zxj6 please do try it and let us know how it goes.

-Manan

Translate
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 ,
Aug 03, 2023 Aug 03, 2023

Dear Mannan,

 

Thank you, we will check ....

Translate
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