2 Replies Latest reply on Aug 8, 2017 1:16 AM by jamesm23048946

    Print xml contents

    sangeethak65390815 Level 1

      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