Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Retrieve multiple xml values to JS file  (Read 3790 times)

0 Members and 1 Guest are viewing this topic.

Venkat

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    Retrieve multiple xml values to JS file
    « on: May 03, 2015, 11:10:16 PM »
    Hi all,

      I am having few xml files with same attrributes having different input values. I have created a js file to take these inputs from single xml file.

    Following is the js code :
    var Nodes = new Array();
    var RaidType;
    function XMLReader()
    {
      var Doc, node, s;
      // Create a COM object
      Doc = Sys.OleObject("Msxml2.DOMDocument.6.0");
      Doc.async = false;
      var Filename = "test.xml";
      // Load data from a file
      Doc.load("C:\\test.xml");
      // Report an error, if, for instance, the markup or file structure is invalid
      // Obtain the node
      node = Doc.documentElement;
      // Process the node
      ProcessNode(node);
    }

    function ProcessNode(ANode)
    {
      var i, ChildNodes;
          // Process the node's value and insert it in variables
      switch(ANode.nodeName)
      {
        case 'Node':
            Nodes[a] = ANode.nodeTypedValue;
            //Nodes = temp.split(" ");
            Log.Message(Nodes[a]);
            a = a + 1;
            break;
        case 'RaidType':
            RaidType = ANode.nodeTypedValue;
            Log.Message(RaidType);
            break;
      }
      // Exclude helper nodes from processing
      // Obtain the collection of child nodes
      ChildNodes = ANode.childNodes;
      // Processes each node of the collection
      for(i = 0; i < ChildNodes.length; i++)
         ProcessNode(ChildNodes.item(i));
    }

    I am Calling below two functions for execution :

    XMLReader();
    startUpgrade();


    Query : As of now, i am able to retrieve values from  test.xml file (only) mentioned above in the code and execute. I need to similarly retrieve values from mutiple xml files ie. first time i need values from test.xml and process below functions:
    XMLReader(); //values of test.xml
    startUpgrade();

    In the next iteration, i need values to be retrieved from abc.xml and process below functions:
    XMLReader(); //values of abc.xml
    startUpgrade();

    In the next iteration, i need values to be retrieved from def.xml and process below functions:
    XMLReader(); //values of def.xml
    startUpgrade();

    Can anyone help me on this as i am really confused on how to get going ??? ???
    Thanks in advance..

    Venkat

      Topic Starter


      Rookie

      • Experience: Experienced
      • OS: Windows 7
      Re: Retrieve multiple xml values to JS file
      « Reply #1 on: May 07, 2015, 12:31:13 AM »
      Issue resolved as i followed same procedure above to retrieve Xml files and paths and fed the inputs to above code by looping them.