Skip to main content
sangeethak65390815
Known Participant
August 7, 2017
Question

Print xml contents

  • August 7, 2017
  • 2 replies
  • 418 views

hai,

I am using javascript for printing xml contents. I can able to get xml file but i don't know how to print xml contents pls any one guide me.

The following code i can tried,

var myFile=File.openDialog("Choose Xml File","*.xml");

myFile.open("r");

var mycontent = myFile.read();

myFile.close(); 

myxml = XML(mycontent);

var myxpath=myxml.xpath("//book[1]")

var myValue=myxpath.attributes()

var myContents=xml_Contents(myxpath,myValue);

alert(myContents)

       

       

function xml_Contents(mxl,mycnt)

{

    var myCont=[];

    try

    {

        var myxm=XML(mxl);

        if(myxm.contains(mycnt)==true)

        {

            myxm.descendants();

       return myCont;

        }

        else

        {

        return null;

        }

    }

    catch(e)

    {

        alert(e);

    }

}

Thanks,

Sangeetha.K

This topic has been closed for replies.

2 replies

jamesm23048946
Participant
August 8, 2017

use this tool to test xml print https//jsonformatter.org/xml-pretty-print

Jongware
Community Expert
Community Expert
August 7, 2017

InDesign cannot "print xml". You need to place it into an InDesign document first, and then print this instead.

If you want to manipulate "pure" XML (including printing it), you may be better off with using other software.