0

I'm using the XML class to parse an XML string. I want to insert the parsed XML into a textbox. What is the proper way to accomplish this?

My Code:

var myXML = new XML( '<?xml version="1.0" encoding="UTF-8"?><root><myText>Hello World</myText></root>' );
app.selection[0].placeXML( myXML );
// app.selection[0].placeXML( myXML.elements()[0] );

This Generates Error 30477:

Invalid value for parameter 'using' of method 'placeXML'. Expected XMLElement, but received nothing.
skibulk
  • 3,088
  • 1
  • 34
  • 42
  • What about ``var myXML = jQuery.parseXML( ' ...`` ? – Jonas M. Schlatter Jan 07 '18 at 16:57
  • @JonasM.Schlatter jquery doesn't even work in indesign? I was also hoping that InDesign would insert the text into the textbox with the tags applied. – skibulk Jan 07 '18 at 17:27
  • 2
    The native JavaScript's XML element is something different than InDesign's version `XMLElement` – they are not freely interchangeable. Either write code to convert it, or (easier and quite possibly faster) save your XML to a file and use InDesign's native methods to load it again. – Jongware Jan 08 '18 at 09:39

0 Answers0