Skip to main content
Known Participant
August 2, 2023
Question

DOM Parser not working in IDJS script

  • August 2, 2023
  • 1 reply
  • 1304 views

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

 

This topic has been closed for replies.

1 reply

Community Expert
August 3, 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

-Manan
Community Expert
August 3, 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-packages-or-nodejs-apis

Could be possible, but you will have to test it

-Manan

-Manan
Known Participant
August 3, 2023

Dear Mannan,

 

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